• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FormField类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addFormField

 /**
  * Add a FormField
  *
  * @param FormField $formField FormField object to add
  */
 public function addFormField(FormField $formField)
 {
     if (isset($this->fields[$formField->getName()])) {
         throw new SWException(sprintf("Field already exists.\n\tForm: %s\n\tField name: ", $this->name, $formField->getName()));
     }
     $this->fields[$formField->getName()] = $formField;
 }
开发者ID:carriercomm,项目名称:NeoBill,代码行数:12,代码来源:Form.class.php


示例2: transform

 public function transform(FormField $field)
 {
     // Look for a performXXTransformation() method on the field itself.
     // performReadonlyTransformation() is a pretty commonly applied method.
     // Otherwise, look for a transformXXXField() method on this object.
     // This is more commonly done in custom transformations
     // We iterate through each array simultaneously, looking at [0] of both, then [1] of both.
     // This provides a more natural failover scheme.
     $transNames = array_reverse(array_values(ClassInfo::ancestry($this->class)));
     $fieldClasses = array_reverse(array_values(ClassInfo::ancestry($field->class)));
     $len = max(sizeof($transNames), sizeof($fieldClasses));
     for ($i = 0; $i < $len; $i++) {
         // This is lets fieldClasses be longer than transNames
         if ($transName = $transNames[$i]) {
             if ($field->hasMethod('perform' . $transName)) {
                 $funcName = 'perform' . $transName;
                 //echo "<li>$field->class used $funcName";
                 return $field->{$funcName}($this);
             }
         }
         // And this one does the reverse.
         if ($fieldClass = $fieldClasses[$i]) {
             if ($this->hasMethod('transform' . $fieldClass)) {
                 $funcName = 'transform' . $fieldClass;
                 //echo "<li>$field->class used $funcName";
                 return $this->{$funcName}($field);
             }
         }
     }
     user_error("FormTransformation:: Can't perform '{$this->class}' on '{$field->class}'", E_USER_ERROR);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:31,代码来源:FormTransformation.php


示例3: setCustomValidationMessage

 /**
  * Add is $Field is required message.
  *
  * @param FormField $field
  * @param $title
  */
 protected function setCustomValidationMessage(FormField $field, $title)
 {
     if (!$field->getCustomValidationMessage()) {
         $message = strip_tags($title) . ' ' . _t('Site.IsRequired', ' is required');
         $field->setCustomValidationMessage($message);
     }
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:13,代码来源:ConsoleForm.php


示例4: AJAXLinkHiddenField

 /**
  * Used for storing the quantity update link for ajax use.
  */
 public function AJAXLinkHiddenField()
 {
     if ($quantitylink = $this->item->setquantityLink()) {
         $attributes = array('type' => 'hidden', 'class' => 'ajaxQuantityField_qtylink', 'name' => $this->MainID() . '_Quantity_SetQuantityLink', 'value' => $quantitylink);
         $formfield = new FormField('hack');
         return $formfield->createTag('input', $attributes);
     }
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:11,代码来源:ShopQuantityField.php


示例5: AJAXLinkHiddenField

 /**
  * Used for storing the quantity update link for ajax use.
  */
 function AJAXLinkHiddenField()
 {
     if ($quantitylink = ShoppingCart::set_quantity_item_link($this->item->getProductIDForSerialization(), null, $this->parameters)) {
         $attributes = array('type' => 'hidden', 'class' => 'ajaxQuantityField_qtylink', 'name' => $this->item->MainID() . '_Quantity_SetQuantityLink', 'value' => $quantitylink);
         $formfield = new FormField('hack');
         return $formfield->createTag('input', $attributes);
     }
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:11,代码来源:EcomQuantityField.php


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


示例7: getFormat

 public function getFormat()
 {
     $fields = AddressFormat::getOrderedAddressFields($this->country->id, true, true);
     $required = array_flip(AddressFormat::getFieldsRequired());
     $format = ['id_address' => (new FormField())->setName('id_address')->setType('hidden'), 'id_customer' => (new FormField())->setName('id_customer')->setType('hidden'), 'back' => (new FormField())->setName('back')->setType('hidden'), 'token' => (new FormField())->setName('token')->setType('hidden'), 'alias' => (new FormField())->setName('alias')->setLabel($this->getFieldLabel('alias'))];
     foreach ($fields as $field) {
         $formField = new FormField();
         $formField->setName($field);
         $fieldParts = explode(':', $field, 2);
         if (count($fieldParts) === 1) {
             if ($field === 'postcode') {
                 if ($this->country->need_zip_code) {
                     $formField->setRequired(true);
                 }
             }
         } elseif (count($fieldParts) === 2) {
             list($entity, $entityField) = $fieldParts;
             // Fields specified using the Entity:field
             // notation are actually references to other
             // entities, so they should be displayed as a select
             $formField->setType('select');
             // Also, what we really want is the id of the linked entity
             $formField->setName('id_' . strtolower($entity));
             if ($entity === 'Country') {
                 $formField->setType('countrySelect');
                 $formField->setValue($this->country->id);
                 foreach ($this->availableCountries as $country) {
                     $formField->addAvailableValue($country['id_country'], $country[$entityField]);
                 }
             } elseif ($entity === 'State') {
                 if ($this->country->contains_states) {
                     $states = State::getStatesByIdCountry($this->country->id);
                     foreach ($states as $state) {
                         $formField->addAvailableValue($state['id_state'], $state[$entityField]);
                     }
                     $formField->setRequired(true);
                 }
             }
         }
         $formField->setLabel($this->getFieldLabel($field));
         if (!$formField->isRequired()) {
             // Only trust the $required array for fields
             // that are not marked as required.
             // $required doesn't have all the info, and fields
             // may be required for other reasons than what
             // AddressFormat::getFieldsRequired() says.
             $formField->setRequired(array_key_exists($field, $required));
         }
         $format[$formField->getName()] = $formField;
     }
     return $this->addConstraints($this->addMaxLength($format));
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:52,代码来源:CustomerAddressFormatter.php


示例8: baseTransform

 /**
  * @param FormField $nonEditableField
  * @param FormField $originalField
  * @param string $fieldname
  * @return CompositeField
  */
 protected function baseTransform($nonEditableField, $originalField, $fieldname)
 {
     /** @var CompositeField $nonEditableField_holder */
     $nonEditableField_holder = CompositeField::create($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:bummzack,项目名称:translatable-dataobject,代码行数:19,代码来源:TranslatableFormFieldTransformation.php


示例9: Field

 public function Field($properties = array())
 {
     $options = '';
     foreach ($this->getSource() as $value => $title) {
         if (is_array($title)) {
             $options .= "<optgroup label=\"{$value}\">";
             foreach ($title as $value2 => $title2) {
                 $disabled = '';
                 if (array_key_exists($value, $this->disabledItems) && is_array($this->disabledItems[$value]) && in_array($value2, $this->disabledItems[$value])) {
                     $disabled = 'disabled="disabled"';
                 }
                 $selected = $value2 == $this->value ? " selected=\"selected\"" : "";
                 $options .= "<option{$selected} value=\"{$value2}\" {$disabled}>{$title2}</option>";
             }
             $options .= "</optgroup>";
         } else {
             // Fall back to the standard dropdown field
             $disabled = '';
             if (in_array($value, $this->disabledItems)) {
                 $disabled = 'disabled="disabled"';
             }
             $selected = $value == $this->value ? " selected=\"selected\"" : "";
             $options .= "<option{$selected} value=\"{$value}\" {$disabled}>{$title}</option>";
         }
     }
     return FormField::create_tag('select', $this->getAttributes(), $options);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:27,代码来源:GroupedDropdownField.php


示例10: getHeading

 /**
  * Gets the heading, or label, for the interface, e.g. "Select the categories for this product"
  *
  * @return string
  */
 public function getHeading()
 {
     if (!$this->get('Heading')) {
         return FormField::name_to_label($this->getParentNode()->transform("BedrockComponent")->getName());
     }
     return $this->get('Heading');
 }
开发者ID:Tangdongle,项目名称:SilverSmith,代码行数:12,代码来源:BedrockInterface.php


示例11: getAreasForPageType

 /**
  * Gets an array of all areas defined for the current theme that are compatible
  * with pages of type $class
  * @param string $class
  * @return array $areas
  **/
 public function getAreasForPageType($class)
 {
     $areas = $this->getAreasForTheme(null, false);
     if (!$areas) {
         return false;
     }
     foreach ($areas as $area => $config) {
         if (!is_array($config)) {
             continue;
         }
         if (isset($config['except'])) {
             $except = $config['except'];
             if (is_array($except) ? in_array($class, $except) : $except == $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
         if (isset($config['only'])) {
             $only = $config['only'];
             if (is_array($only) ? !in_array($class, $only) : $only != $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
     }
     if (count($areas)) {
         foreach ($areas as $k => $v) {
             $areas[$k] = FormField::name_to_label($k);
         }
         return $areas;
     } else {
         return $areas;
     }
 }
开发者ID:mhssmnn,项目名称:silverstripe-blocks,代码行数:40,代码来源:BlockManager.php


示例12: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $extFields = self::$db;
     $fields->removeByName(array_keys($extFields));
     if (!$this->owner->WordpressID) {
         return;
     }
     $compositeFields = array();
     foreach ($extFields as $name => $type) {
         $value = $this->owner->getField($name);
         $compositeFields[$name] = ReadonlyField::create($name . '_Readonly', FormField::name_to_label($name), $value);
     }
     if ($compositeFields) {
         $wordpressCompositeField = ToggleCompositeField::create('WordpressCompositeField', 'Wordpress', $compositeFields)->setHeadingLevel(4);
         if ($fields->fieldByName('Metadata')) {
             $fields->insertBefore($wordpressCompositeField, 'Metadata');
         } else {
             if ($fields->fieldByName('Root')) {
                 $fields->addFieldToTab('Root.Main', $wordpressCompositeField);
             } else {
                 $fields->push($wordpressCompositeField);
             }
         }
     }
 }
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:25,代码来源:WordpressImportDataExtension.php


示例13: testErrors

 public function testErrors()
 {
     $form = Form::create()->add(Primitive::ternary('flag')->setFalseValue('0')->setTrueValue('1'))->add(Primitive::integer('old')->required())->addRule('someRule', Expression::between(FormField::create('old'), '18', '35'));
     //empty import
     $form->import(array())->checkRules();
     //checking
     $expectingErrors = array('old' => Form::MISSING, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertEquals(Form::MISSING, $form->getError('old'));
     $this->assertEquals(Form::WRONG, $form->getError('someRule'));
     $this->assertTrue($form->hasError('old'));
     $this->assertFalse($form->hasError('flag'));
     //drop errors
     $form->dropAllErrors();
     $this->assertEquals(array(), $form->getErrors());
     //import wrong data
     $form->clean()->importMore(array('flag' => '3', 'old' => '17'))->checkRules();
     //checking
     $expectingErrors = array('flag' => Form::WRONG, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertTrue($form->hasError('someRule'));
     //marking good and custom check errors
     $form->markGood('someRule')->markCustom('flag', 3);
     $this->assertEquals(array('flag' => 3), $form->getErrors());
     $this->assertFalse($form->hasError('someRule'));
     $this->assertNull($form->getError('someRule'));
     $this->assertEquals(3, $form->getError('flag'));
     //import right data
     $form->dropAllErrors()->clean()->importMore(array('flag' => '1', 'old' => '35'));
     //checking
     $this->assertEquals(array(), $form->getErrors());
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:32,代码来源:FormTest.class.php


示例14: handlePost

 protected function handlePost(array $data, $settings = [])
 {
     $post = ['ID' => isset($data['id']) && isset($data['id']['videoId']) ? $data['id']['videoId'] : '0', 'Author' => isset($data['snippet']) && isset($data['snippet']['channelTitle']) ? \FormField::name_to_label($data['snippet']['channelTitle']) : '', 'AuthorID' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? $data['snippet']['channelId'] : 0, 'AuthorURL' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? \Controller::join_links($this->url, 'channel', $data['snippet']['channelId']) : '', 'Title' => isset($data['snippet']) && isset($data['snippet']['title']) ? $data['snippet']['title'] : '', 'Content' => isset($data['snippet']) && isset($data['snippet']['description']) ? $this->textParser()->text($data['snippet']['description']) : '', 'Priority' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? strtotime($data['snippet']['publishedAt']) : 0, 'Posted' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? \DBField::create_field('SS_Datetime', strtotime($data['snippet']['publishedAt'])) : null];
     if (isset($data['snippet']) && isset($data['snippet']['thumbnails'])) {
         if (isset($data['snippet']['thumbnails']['high']) && isset($data['snippet']['thumbnails']['high']['url'])) {
             $post['Cover'] = $data['snippet']['thumbnails']['high']['url'];
         } else {
             if (isset($data['snippet']['thumbnails']['medium']) && isset($data['snippet']['thumbnails']['medium']['url'])) {
                 $post['Cover'] = $data['snippet']['thumbnails']['medium']['url'];
             } else {
                 if (isset($data['snippet']['thumbnails']['default']) && isset($data['snippet']['thumbnails']['default']['url'])) {
                     $post['Cover'] = $data['snippet']['thumbnails']['default']['url'];
                 }
             }
         }
     }
     if ($post['ID']) {
         $params = (array) singleton('env')->get('Youtube.video_params');
         if (isset($settings['videoParams'])) {
             $params = array_merge($params, (array) $settings['videoParams']);
         }
         $params['v'] = $post['ID'];
         $post['Link'] = \Controller::join_links($this->url, 'watch', '?' . http_build_query($params));
         $this->setFromEmbed($post);
     }
     if (isset($post['ObjectDescription']) && $post['ObjectDescription'] == $post['Content']) {
         unset($post['ObjectDescription']);
     }
     if (isset($post['Description']) && $post['Description'] == $post['Content']) {
         unset($post['Description']);
     }
     return $post;
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:33,代码来源:Youtube.php


示例15: __construct

 /**
  * @param string $name Identifier
  * @param string $title (Optional) Natural language title of the tabset
  * @param Tab|TabSet $unknown All further parameters are inserted as children into the TabSet
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = $name;
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     if ($args) {
         foreach ($args as $tab) {
             $isValidArg = is_object($tab) && (!$tab instanceof Tab || !$tab instanceof TabSet);
             if (!$isValidArg) {
                 user_error('TabSet::__construct(): Parameter not a valid Tab instance', E_USER_ERROR);
             }
             $tab->setTabSet($this);
         }
     }
     parent::__construct($args);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:31,代码来源:TabSet.php


示例16: Field

 public function Field($properties = array())
 {
     $source = $this->getSource();
     $options = array();
     if ($source) {
         // SQLMap needs this to add an empty value to the options
         if (is_object($source) && $this->emptyString) {
             $options[] = new ArrayData(array('Value' => '', 'Title' => $this->emptyString));
         }
         foreach ($source as $value => $params) {
             $selected = false;
             if ($value === '' && ($this->value === '' || $this->value === null)) {
                 $selected = true;
             } else {
                 // check against value, fallback to a type check comparison when !value
                 if ($value) {
                     $selected = $value == $this->value;
                 } else {
                     $selected = $value === $this->value || (string) $value === (string) $this->value;
                 }
                 $this->isSelected = $selected;
             }
             $disabled = false;
             if (in_array($value, $this->disabledItems) && $params['Title'] != $this->emptyString) {
                 $disabled = 'disabled';
             }
             $options[] = new ArrayData(array('Title' => $params['Title'], 'Value' => $value, 'Selected' => $selected, 'Disabled' => $disabled, 'Attributes' => $this->createOptionAttributes($params)));
         }
     }
     $properties = array_merge($properties, array('Options' => new ArrayList($options)));
     return FormField::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:dnadesign-silverstripe-advanceddropdowns,代码行数:32,代码来源:AdvancedDropdownField.php


示例17: Field

 public function Field($properties = array())
 {
     if (!isset($properties['ID'])) {
         $properties['ID'] = $this->ID();
     }
     if (!isset($properties['Title']) && $this->Title()) {
         $properties['Title'] = $this->Title();
     }
     if (!isset($properties['AttributesHTML'])) {
         $properties['AttributesHTML'] = $this->AttributesHTML;
     }
     if (!isset($properties['NoClose']) && !$this->allowClose) {
         $properties['NoClose'] = true;
     }
     if ((!isset($properties['Trigger']) || isset($properties['TriggerButton'])) && $this->modalTrigger) {
         if ($this->modalTrigger instanceof FormActionLink) {
             $this->modalTrigger->triggerModal($this->ID());
         }
         if ($this->modalTrigger instanceof FormField) {
             $properties['TriggerButton'] = $this->modalTrigger;
         } else {
             $properties['Trigger'] = $this->modalTrigger;
         }
     }
     if (!isset($properties['FieldList']) && $this->children) {
         $properties['FieldList'] = $this->children;
     }
     if (!isset($properties['FooterFields']) && $this->footer) {
         $properties['FooterFields'] = $this->footer;
     }
     return parent::FieldHolder($properties);
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-mwm-formfields,代码行数:32,代码来源:ModalWindowComponentField.php


示例18: setName

 /**
  * (non-PHPdoc)
  * @see forms/FormField#setName($name)
  */
 function setName($name)
 {
     // We need to pass through the name change to the underlying value field.
     $this->valueField->setName($name);
     parent::setName($name);
     return $this;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:11,代码来源:NullableField.php


示例19: __construct

 public function __construct($name, $title = null, $value = '', $extension = null, $areaCode = null, $countryCode = null)
 {
     $this->areaCode = $areaCode;
     $this->ext = $extension;
     $this->countryCode = $countryCode;
     parent::__construct($name, $title, $value);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:7,代码来源:PhoneNumberField.php


示例20:

 /**
  * Create a new action button.
  * @param action The method to call when the button is clicked
  * @param title The label on the button
  * @param form The parent form, auto-set when the field is placed inside a form 
  * @param extraData A piece of extra data that can be extracted with $this->extraData.  Useful for
  *                  calling $form->buttonClicked()->extraData()
  * @param extraClass A CSS class to apply to the button in addition to 'action'
  */
 function __construct($action, $title = "", $form = null, $extraData = null, $extraClass = '')
 {
     $this->extraData = $extraData;
     $this->extraClass = ' ' . $extraClass;
     $this->action = "action_{$action}";
     parent::__construct($this->action, $title, null, $form);
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:16,代码来源:FormAction.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FormFile类代码示例发布时间:2022-05-23
下一篇:
PHP FormFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap