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


PHP FormField::addExtraClass方法代码示例

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


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

示例1: __construct

 public function __construct($name, $title = null, $value = null, $form = null)
 {
     // Create a callable function that returns an array of options for the DependentDropdownField.
     // When the value of the field it depends on changes, this function is called passing the
     // updated value as the first parameter ($val)
     $getanchors = function ($page_id) {
         // Copied from HtmlEditorField_Toolbar::getanchors()
         if (($page = Page::get()->byID($page_id)) && !empty($page)) {
             //			if (!$page->canView()) { /* ERROR? */ }
             // Similar to the regex found in HtmlEditorField.js / getAnchors method.
             if (preg_match_all("/\\s(name|id)=\"([^\"]+?)\"|\\s(name|id)='([^']+?)'/im", $page->Content, $matches)) {
                 //					var_dump(array_filter(array_merge($matches[2], $matches[4])));
                 $anchors = array_filter(array_merge($matches[2], $matches[4]));
                 return array_combine($anchors, $anchors);
             }
         }
     };
     // naming with underscores to prevent values from actually being saved somewhere
     $this->fieldCustomURL = new TextField("{$name}[CustomURL]", '', '', 300, $form);
     $this->fieldShortcode = new TextField("{$name}[Shortcode]", '', '', 300, $form);
     $this->fieldPageID = new TreeDropdownField("{$name}[PageID]", '', 'SiteTree', 'ID', 'MenuTitle');
     $this->fieldPageID->setForm($form);
     //		$this->fieldPageAnchor = new DropdownField("{$name}[PageAnchor]", 'Anchor:',array(), '', $form);
     // The DependentDropdownField, setting the source as the callable function
     // and setting the field it depends on to the appropriate field
     $this->fieldPageAnchor = DependentDropdownField::create("{$name}[PageAnchor]", 'Text-anchor:', $getanchors, $form)->setEmptyString('Page anchor: (none)')->setDepends($this->fieldPageID);
     $this->fieldFileID = new TreeDropdownField("{$name}[FileID]", '', 'File', 'ID', 'Name');
     $this->fieldFileID->addExtraClass('filetree');
     $this->fieldFileID->setForm($form);
     $this->fieldTitle = new TextField("{$name}[Title]", 'Title: ', '', 300, $form);
     $this->fieldLinkmode = new DropdownField("{$name}[Linkmode]", 'Type: ', array('Page' => 'Page', 'URL' => 'URL', 'File' => 'File', 'Email' => 'Email', 'Shortcode' => 'Shortcode'), '', $form);
     $this->fieldLinkmode->addExtraClass('LinkModePicker');
     parent::__construct($name, $title, $value, $form);
 }
开发者ID:micschk,项目名称:silverstripe-namedlinkfield,代码行数:34,代码来源:NamedLinkFormField.php

示例2: __construct

 public function __construct($name, $title = null, $value = null, $form = null)
 {
     // naming with underscores to prevent values from actually being saved somewhere
     $this->fieldCustomURL = new TextField("{$name}[CustomURL]", '', '', 300, $form);
     $this->fieldPageID = new TreeDropdownField("{$name}[PageID]", '', 'SiteTree', 'ID', 'Title');
     $this->fieldTitle = new TextField("{$name}[Title]", 'Title: ', '', 300, $form);
     $this->fieldLinkmode = new DropdownField("{$name}[Linkmode]", 'Type: ', array('internal' => 'Internal', 'external' => 'External'), '', $form);
     $this->fieldLinkmode->addExtraClass('LinkModePicker');
     $this->fieldPageID->setForm($form);
     parent::__construct($name, $title, $value, $form);
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-namedlinkfield,代码行数:11,代码来源:NamedLinkFormField.php

示例3: testRemoveManyExtraClasses

 public function testRemoveManyExtraClasses()
 {
     $field = new FormField('MyField');
     $field->addExtraClass('class1 class2     class3	class4		class5');
     //test we can remove a single class we just added
     $field->removeExtraClass('class3');
     $this->assertStringEndsWith('class1 class2 class4 class5', $field->extraClass());
     //check we can remove many classes at once
     $field->removeExtraClass('class1 class5');
     $this->assertStringEndsWith('class2 class4', $field->extraClass());
     //check that removing a dud class is fine
     $field->removeExtraClass('dudClass');
     $this->assertStringEndsWith('class2 class4', $field->extraClass());
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:14,代码来源:FormFieldTest.php

示例4: addExtraClass

 /**
  * Override addExtraClass
  * 
  * @param string $class
  */
 public function addExtraClass($class)
 {
     $this->fieldPostcode->addExtraClass($class);
     $this->fieldCountry->addExtraClass($class);
     return $this;
 }
开发者ID:helpfulrobot,项目名称:andrelohmann-silverstripe-geoform,代码行数:11,代码来源:PostCodeLocationField.php

示例5: onBeforeRender

 /**
  * Adds the form-control class to *just* the formfield, not the holder.
  * This seems a bit of a hack, but addExtraClass() affects both the holder
  * and the field, so that's not a realistic option. We can't have form-control
  * on the wrapping div.
  * 
  * @param  FormField $field	 
  */
 public function onBeforeRender(FormField $field)
 {
     $inline_fields = Config::inst()->get('BootstrapForm', 'inline_fields');
     if (!in_array($field->class, $inline_fields)) {
         $field->addExtraClass('form-control');
     }
 }
开发者ID:helpfulrobot,项目名称:unclecheese-bootstrap-forms,代码行数:15,代码来源:BootstrapFormField.php

示例6: addExtraClass

 /**
  * Add the extra class to our child elements too
  * {@inheritdoc}
  */
 public function addExtraClass($class)
 {
     parent::addExtraClass($class);
     foreach ($this->getChildren() as $childField) {
         $childField->addExtraClass($class);
     }
     return $this;
 }
开发者ID:helpfulrobot,项目名称:betterbrief-silverstripe-autocompletefield,代码行数:12,代码来源:AutocompleteField.php

示例7: baseTransform

 /**
  * Transform a translatable field to show the field value from the default language
  * DataObject below the translated field.
  * 
  * This is a fallback function which handles field types that aren't transformed by
  * $this->transform{FieldType} functions.
  * 
  * @param FormField $nonEditableField The readonly field to contain the original value
  * @param FormField $originalField The original editable field containing the translated value
  * @return \CompositeField The transformed field
  */
 protected function baseTransform($nonEditableField, $originalField)
 {
     $fieldname = $originalField->getName();
     $nonEditableField_holder = new CompositeField($nonEditableField);
     $nonEditableField_holder->setName($fieldname . '_holder');
     $nonEditableField_holder->addExtraClass('originallang_holder');
     $nonEditableField->setValue($this->original->{$fieldname});
     $nonEditableField->setName($fieldname . '_original');
     $nonEditableField->addExtraClass('originallang');
     $nonEditableField->setTitle(_t('Translatable_Transform.OriginalFieldLabel', 'Original {title}', 'Label for the original value of the translatable field.', array('title' => $originalField->Title())));
     $nonEditableField_holder->insertBefore($originalField, $fieldname . '_original');
     return $nonEditableField_holder;
 }
开发者ID:camfindlay,项目名称:silverstripe-translatable,代码行数:24,代码来源:Translatable.php

示例8: 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

示例9: addExtraClass

 /**
  * Override addExtraClass
  * 
  * @param string $class
  */
 public function addExtraClass($class)
 {
     $this->fieldLatitude->addExtraClass($class);
     $this->fieldLongditude->addExtraClass($class);
     return $this;
 }
开发者ID:helpfulrobot,项目名称:andrelohmann-silverstripe-geoform,代码行数:11,代码来源:LocationField.php

示例10: addExtraClass

 /**
  * Override addExtraClass
  * 
  * @param string $class
  */
 public function addExtraClass($class)
 {
     $this->fieldAddress->addExtraClass($class);
     return $this;
 }
开发者ID:helpfulrobot,项目名称:andrelohmann-silverstripe-geoform,代码行数:10,代码来源:BackendGeoLocationField.php

示例11: apply

 /**
  * @param ISurveyStep $current_step
  * @param ISurveyQuestionTemplate $question
  * @param array $js_rules
  * @param FormField $field
  */
 public function apply(ISurveyStep $current_step, ISurveyQuestionTemplate $question, array $js_rules, FormField $field)
 {
     if (count($js_rules)) {
         $js = "jQuery(document).ready(function(\$){\n\n                    var form                = \$('.survey_step_form');\n                    var form_id             = form.attr('id');\n                    var clickable_fields    = [];\n                    var selectable_fields   = [];\n                    var rankable_fields     = [];\n                    var double_table_fields = [];\n                    ";
         //hide and set js rule
         $field->addExtraClass('hidden');
         $question_id = $question->name();
         foreach ($js_rules as $id => $info) {
             $d = $info['question'];
             $values = $info['values'];
             $operator = $info['operator'];
             $visibility = $info['visibility'];
             if ($d instanceof ISurveyClickableQuestion || $d instanceof ISurveyRankableQuestion || $d instanceof IDoubleEntryTableQuestionTemplate) {
                 foreach ($values as $value) {
                     $option_id = $d->name();
                     if ($d instanceof ISurveyClickableQuestion) {
                         if ($d instanceof IMultiValueQuestionTemplate && intval($value) > 0) {
                             //$value = $d->getValueById(intval($d->ValueID));
                             $option_id .= '_' . str_replace(' ', '', intval($value));
                         }
                         $js .= " clickable_fields.push(\$('#'+form_id+'_{$option_id}'));";
                     }
                     if ($d instanceof ISurveyRankableQuestion) {
                         if ($d instanceof IMultiValueQuestionTemplate && intval($value) > 0) {
                             if ($d instanceof IMultiValueQuestionTemplate && intval($value) > 0) {
                                 //$value = $d->getValueById(intval($d->ValueID));
                                 $option_id .= '_' . str_replace(' ', '', intval($value));
                             }
                             $js .= " rankable_fields.push( \$('#'+form_id+'_{$option_id}') );";
                         }
                     }
                     if ($d instanceof IDoubleEntryTableQuestionTemplate) {
                         $js .= " double_table_fields.push({table : \$('#'+'{$option_id}'), value: {$value} });";
                     }
                 }
             }
             if ($d instanceof ISurveySelectableQuestion && $d instanceof IMultiValueQuestionTemplate) {
                 $option_id = $d->name();
                 $values = implode(',', $values);
                 $js .= " selectable_fields.push({ddl : \$('#'+form_id+'_{$option_id}'), values: [{$values}] });";
             }
         }
         $js .= "for(var i = 0 ; i < selectable_fields.length; i++ ){\n                form.survey_validation_rules('addRequiredAnswer4SelectAbleGroup', selectable_fields, \$('#{$question_id}'));\n                }";
         $js .= "if(clickable_fields.length > 0 )\n                form.survey_validation_rules('addRequiredAnswer4CheckAbleGroup', clickable_fields, \$('#{$question_id}') ); ";
         $js .= "if(rankable_fields.length > 0 )\n                form.survey_validation_rules('addRequiredAnswer4RankAbleGroup', rankable_fields, \$('#{$question_id}') );";
         $js .= "if(double_table_fields.length > 0 )\n                form.survey_validation_rules('addRequiredAnswer4TableGroup', double_table_fields, \$('#{$question_id}') );\n                });";
         Requirements::customScript($js);
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:55,代码来源:AbstractSurveyQuestionTemplateUIBuilder.php


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