Documentation

setAttributes

Attention! We strongly recommend first to learn more about Sites module REST documentation to understand how the module functions (with REST available in Bitrix24 Self-hosted editions). View this documentation as useful source when working with Bitrix24 Self-hosted editions and find out more details about API and only REST is not enough.

public function setAttributes(
   $data
)

Sets selector attributes. Attributes must be included in manifest to complete the update. Returns true on success.

Parameters

Class Description Available from version
data Array to be updated. Keys are: selector with paired array "position number" = "changed attributes" (pair of attribute=value). Counting from zero. See more details in example.

Example

if (\Bitrix\Main\Loader::includeModule('landing'))
{
   \Bitrix\Landing\Landing::setEditMode(true);

   $landing = \Bitrix\Landing\Landing::createInstance(
      5675
   );
   if ($landing->exist())
   {
      foreach ($landing->getBlocks() as $block)
      {
         if ($block->getId() == 46613)
         {
            $block->setAttributes([
               '.landing-block-node-title' => [
                  1 => [
                     'data-b24form' => 'jvu5mv'
                  ]
               ]
            ]);
            $block->save();
            $landing->getError()->copyError(
               $block->getError()
            );
         }
      }
   }


   foreach ($landing->getError()->getErrors() as $error)
   {
      echo $error->getCode() . ': ';
      echo $error->getMessage();
      echo "\n";
   }
}
 


© «Bitrix24», 2001-2024
Up