本文整理汇总了PHP中GridField_FormAction::setReadonly方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField_FormAction::setReadonly方法的具体用法?PHP GridField_FormAction::setReadonly怎么用?PHP GridField_FormAction::setReadonly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField_FormAction
的用法示例。
在下文中一共展示了GridField_FormAction::setReadonly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHTMLFragments
/**
*
* @param GridField $gridField
* @return string - HTML
*/
public function getHTMLFragments($gridField)
{
$searchState = $gridField->State->GridFieldSearchRelation;
$dataClass = $gridField->getList()->dataClass();
$forTemplate = new ArrayData(array());
$forTemplate->Fields = new ArrayList();
$searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
$value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
$searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
// Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
$searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
$searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
$searchField->addExtraClass('relation-search no-change-track');
$findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
$findAction->setAttribute('data-icon', 'relationfind');
$addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
$addAction->setAttribute('data-icon', 'chain--plus');
// If an object is not found, disable the action
if (!is_int($gridField->State->GridFieldAddRelation)) {
$addAction->setReadonly(true);
}
$forTemplate->Fields->push($searchField);
$forTemplate->Fields->push($findAction);
$forTemplate->Fields->push($addAction);
return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
}
示例2: getHTMLFragments
/**
*
* @param GridField $gridField
* @return string - HTML
*/
public function getHTMLFragments($gridField)
{
$dataClass = $gridField->getList()->dataClass();
$forTemplate = new ArrayData(array());
$forTemplate->Fields = new ArrayList();
$searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"));
$searchField->setAttribute('data-search-url', Controller::join_links($gridField->Link('search')));
$searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
$searchField->addExtraClass('relation-search no-change-track');
$findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
$findAction->setAttribute('data-icon', 'relationfind');
$addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
$addAction->setAttribute('data-icon', 'chain--plus');
// If an object is not found, disable the action
if (!is_int($gridField->State->GridFieldAddRelation(null))) {
$addAction->setReadonly(true);
}
$forTemplate->Fields->push($searchField);
$forTemplate->Fields->push($findAction);
$forTemplate->Fields->push($addAction);
return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
}