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


PHP OptionsetField::addExtraClass方法代码示例

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


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

示例1: testFieldHasExtraClass

 function testFieldHasExtraClass()
 {
     /* TextField has an extra class name and is in the HTML the field returns */
     $textField = new TextField('Name');
     $textField->addExtraClass('thisIsMyClassNameForTheFormField');
     preg_match('/thisIsMyClassNameForTheFormField/', $textField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyClassNameForTheFormField');
     /* EmailField has an extra class name and is in the HTML the field returns */
     $emailField = new EmailField('Email');
     $emailField->addExtraClass('thisIsMyExtraClassForEmailField');
     preg_match('/thisIsMyExtraClassForEmailField/', $emailField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyExtraClassForEmailField');
     /* OptionsetField has an extra class name and is in the HTML the field returns */
     $optionsetField = new OptionsetField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)');
     $optionsetField->addExtraClass('thisIsMyExtraClassForOptionsetField');
     preg_match('/thisIsMyExtraClassForOptionsetField/', $optionsetField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyExtraClassForOptionsetField');
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:18,代码来源:FormFieldTest.php

示例2: buildPosts

 private function buildPosts(&$request, &$fields)
 {
     $posts = $request->data;
     $unmoderatedCount = 0;
     foreach ($posts as $post) {
         $moderated = DataObject::get('InstagramPost')->filter(array('MediaID' => $post->id));
         if (!$moderated->count()) {
             $postData = '<div class="post"><img src="' . $post->images->standard_resolution->url . '" width="300" height="300" alt="" /><p>' . $post->caption->text . '</p></div>';
             $postField = new OptionsetField($name = 'Instagram_' . $post->id, $title = $postData, $source = array("approve" => "Approve", "reject" => "Reject"));
             $imageField = new HiddenField('ImageData_' . $post->id, 'ImageData_' . $post->id, json_encode(array('images' => $post->images, 'link' => $post->link)));
             $postField->addExtraClass('instagram-post');
             $fields->add($postField);
             $fields->add($imageField);
             $unmoderatedCount++;
         }
     }
     if (!$unmoderatedCount) {
         $request = $this->requestPosts($request->pagination->next_url);
         $this->buildPosts($request, $fields);
     }
 }
开发者ID:one20,项目名称:silverstripe-instagram-moderation,代码行数:21,代码来源:InstagramPost.php

示例3: getCMSFields

 /**
  * Returns a FieldList with which to create the CMS editing form
  *
  * @return FieldList The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     Requirements::javascript("forum/javascript/ForumAccess.js");
     Requirements::css("forum/css/Forum_CMS.css");
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Access", new HeaderField(_t('Forum.ACCESSPOST', 'Who can post to the forum?'), 2));
     $fields->addFieldToTab("Root.Access", $optionSetField = new OptionsetField("CanPostType", "", array("Inherit" => "Inherit", "Anyone" => _t('Forum.READANYONE', 'Anyone'), "LoggedInUsers" => _t('Forum.READLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('Forum.READLIST', 'Only these people (choose from list)'), "NoOne" => _t('Forum.READNOONE', 'Nobody. Make Forum Read Only'))));
     $optionSetField->addExtraClass('ForumCanPostTypeSelector');
     $fields->addFieldsToTab("Root.Access", array(new TreeMultiselectField("PosterGroups", _t('Forum.GROUPS', "Groups")), new OptionsetField("CanAttachFiles", _t('Forum.ACCESSATTACH', 'Can users attach files?'), array("1" => _t('Forum.YES', 'Yes'), "0" => _t('Forum.NO', 'No')))));
     //Dropdown of forum category selection.
     $categories = ForumCategory::get()->map();
     $fields->addFieldsToTab("Root.Main", DropdownField::create('CategoryID', _t('Forum.FORUMCATEGORY', 'Forum Category'), $categories), 'Content');
     //GridField Config - only need to attach or detach Moderators with existing Member accounts.
     $moderatorsConfig = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldAddExistingAutocompleter('buttons-before-right'))->addComponent(new GridFieldToolbarHeader())->addComponent($sort = new GridFieldSortableHeader())->addComponent($columns = new GridFieldDataColumns())->addComponent(new GridFieldDeleteAction(true))->addComponent(new GridFieldPageCount('toolbar-header-right'))->addComponent($pagination = new GridFieldPaginator());
     // Use GridField for Moderator management
     $moderators = GridField::create('Moderators', _t('MODERATORS', 'Moderators for this forum'), $this->Moderators(), $moderatorsConfig);
     $columns->setDisplayFields(array('Nickname' => 'Nickname', 'FirstName' => 'First name', 'Surname' => 'Surname', 'Email' => 'Email', 'LastVisited.Long' => 'Last Visit'));
     $sort->setThrowExceptionOnBadDataType(false);
     $pagination->setThrowExceptionOnBadDataType(false);
     $fields->addFieldToTab('Root.Moderators', $moderators);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:27,代码来源:Forum.php


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