当前位置: 首页>>代码示例>>PHP>>正文


PHP FormField::setAttribute方法代码示例

本文整理汇总了PHP中FormField::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormField::setAttribute方法的具体用法?PHP FormField::setAttribute怎么用?PHP FormField::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormField的用法示例。


在下文中一共展示了FormField::setAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAttributesHTML

 public function testAttributesHTML()
 {
     $field = new FormField('MyField');
     $field->setAttribute('foo', 'bar');
     $this->assertContains('foo="bar"', $field->getAttributesHTML());
     $field->setAttribute('foo', null);
     $this->assertNotContains('foo=', $field->getAttributesHTML());
     $field->setAttribute('foo', '');
     $this->assertNotContains('foo=', $field->getAttributesHTML());
     $field->setAttribute('foo', false);
     $this->assertNotContains('foo=', $field->getAttributesHTML());
     $field->setAttribute('foo', true);
     $this->assertContains('foo="foo"', $field->getAttributesHTML());
     $field->setAttribute('foo', 'false');
     $this->assertContains('foo="false"', $field->getAttributesHTML());
     $field->setAttribute('foo', 'true');
     $this->assertContains('foo="true"', $field->getAttributesHTML());
     $field->setAttribute('foo', 0);
     $this->assertContains('foo="0"', $field->getAttributesHTML());
     $field->setAttribute('one', 1);
     $field->setAttribute('two', 2);
     $field->setAttribute('three', 3);
     $this->assertNotContains('one="1"', $field->getAttributesHTML('one', 'two'));
     $this->assertNotContains('two="2"', $field->getAttributesHTML('one', 'two'));
     $this->assertContains('three="3"', $field->getAttributesHTML('one', 'two'));
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:26,代码来源:FormFieldTest.php

示例2: setPlaceHolder

 /**
  * @param FormField $f
  * @param string $surfix
  * @return static
  */
 protected function setPlaceHolder(FormField $f, $surfix = '')
 {
     $str = $f->Title();
     if ($surfix) {
         $str .= " {$surfix}";
     }
     $f->setAttribute('placeholder', $str);
     return $this;
 }
开发者ID:kbrauer,项目名称:silverstripe-boilerplate,代码行数:14,代码来源:BaseForm.php

示例3: addPart

 /**
  * @return FormField
  */
 public function addPart(FormField $part)
 {
     if (strval($part->getName()) === '') {
         $part->setName(sprintf('%s-%s', $this->getName(), count($this->parts)));
     }
     $part->setAttribute('data-part', count($this->parts));
     $this->parts[] = $part;
     return $this;
 }
开发者ID:helpfulrobot,项目名称:nblum-silverstripe-customizableinputfield,代码行数:12,代码来源:CustomizableInputFieldSet.php

示例4: removeParsley

 /**
  * Removes the html attributes required for frontend validation
  * Subclasses should call parent::removeParsley
  * @return void
  * */
 public function removeParsley()
 {
     $this->parsleyApplied = false;
     if ($this->field && $this->customMessage) {
         $this->field->setAttribute(sprintf('data-parsley-%s-message', $this->getConstraintName()), '');
     }
     if (get_class($this->field) === 'CheckboxSetField') {
         $this->field->setAttribute('data-parsley-multiple', '');
     }
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-zenvalidator,代码行数:15,代码来源:ZenValidatorConstraint.php

示例5: setCountryAttribute

 public function setCountryAttribute($name, $value)
 {
     $this->fieldCountry->setAttribute($name, $value);
     return $this;
 }
开发者ID:helpfulrobot,项目名称:andrelohmann-silverstripe-geoform,代码行数:5,代码来源:PostCodeLocationField.php

示例6: updateFormField

 /**
  * Updates a formfield with the additional metadata specified by this field
  *
  * @param FormField $field
  */
 protected function updateFormField($field)
 {
     // set the error / formatting messages
     $field->setCustomValidationMessage($this->getErrorMessage());
     // set the right title on this field
     if ($this->RightTitle) {
         // Since this field expects raw html, safely escape the user data prior
         $field->setRightTitle(Convert::raw2xml($this->RightTitle));
     }
     // if this field is required add some
     if ($this->Required) {
         // Required validation can conflict so add the Required validation messages as input attributes
         $errorMessage = $this->getErrorMessage()->HTML();
         $field->addExtraClass('requiredField');
         $field->setAttribute('data-rule-required', 'true');
         $field->setAttribute('data-msg-required', $errorMessage);
         if ($identifier = UserDefinedForm::config()->required_identifier) {
             $title = $field->Title() . " <span class='required-identifier'>" . $identifier . "</span>";
             $field->setTitle($title);
         }
     }
     // if this field has an extra class
     if ($this->ExtraClass) {
         $field->addExtraClass($this->ExtraClass);
     }
 }
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:31,代码来源:EditableFormField.php


注:本文中的FormField::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。