本文整理汇总了PHP中HiddenField::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP HiddenField::setAttribute方法的具体用法?PHP HiddenField::setAttribute怎么用?PHP HiddenField::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HiddenField
的用法示例。
在下文中一共展示了HiddenField::setAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateLinkForm
public function updateLinkForm($form)
{
Requirements::javascript("linkableobjects/javascript/CustomHtmlEditorField.js");
$count = 0;
foreach ($form->Fields() as $field) {
$count++;
if ($count == 2) {
$linkType = $field->fieldByName('LinkType');
$types = $linkType->getSource();
$link = new HtmlEditorField_LinkObjects();
$linkableObjects = $link->getLinkableObjects();
foreach ($linkableObjects as $object => $title) {
$types[$object] = $title;
$picker = new DataObjectPicker($object . 'LinkID', $title);
$picker->setConfig('limit', 5);
$picker->setConfig('classToPick', $object);
$picker->setForm($form);
$field->insertBefore($picker, 'Description');
}
$linkMap = new HiddenField('LinkableObjects');
$linkMap->setAttribute('data-map', json_encode($linkableObjects));
$field->push($linkMap);
$linkType->setSource($types);
}
}
}
示例2: ItemEditForm
/**
* Builds an item edit form
*
* @return Form
*/
public function ItemEditForm()
{
// If there are no record set, redirect back to the "main" model admin
if (empty($this->record) || $this->record->ID == 0) {
$controller = Controller::curr();
$noActionURL = $controller->removeAction($_REQUEST['url']);
$controller->getResponse()->removeHeader('Location');
//clear the existing redirect
return $controller->redirect($noActionURL, 302);
}
// Create form field
$fields = new FieldList();
$chartData = new HiddenField('FlowchartData');
$chartData->setAttribute('data-chart-storage', 'true');
$fields->push($chartData);
$existsOnLive = $this->record->getExistsOnLive();
// Create the action buttons
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
$actions = new FieldList(array($majorActions));
if ($this->record->canEdit()) {
$majorActions->push(FormAction::create('doSave', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
}
if ($this->record->canPublish() && !$this->record->IsDeletedFromStage) {
// "publish", as with "save", it supports an alternate state to show when action is needed.
$majorActions->push($publish = FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true));
// Set up the initial state of the button to reflect the state of the underlying SiteTree object.
if ($this->record->stagesDiffer('Stage', 'Live')) {
$publish->addExtraClass('ss-ui-alternate');
}
}
$form = new Form($this, 'ItemEditForm', $fields, $actions);
$form->loadDataFrom($this->record);
$form->Backlink = $this->getBackLink();
$form->setTemplate('Flowchart_EditForm');
return $form;
}