本文整理匯總了PHP中Drupal\Core\Field\WidgetBase::form方法的典型用法代碼示例。如果您正苦於以下問題:PHP WidgetBase::form方法的具體用法?PHP WidgetBase::form怎麽用?PHP WidgetBase::form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Field\WidgetBase
的用法示例。
在下文中一共展示了WidgetBase::form方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: form
/**
* {@inheritdoc}
*/
public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL)
{
$ret = parent::form($items, $form, $form_state, $get_delta);
$field_name = $this->fieldDefinition->getName();
// Add a new wrapper around all the elements for Ajax replacement.
$ret['#prefix'] = '<div id="' . $field_name . '-ajax-wrapper">';
$ret['#suffix'] = '</div>';
return $ret;
}
示例2: form
/**
* {@inheritdoc}
*/
public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL)
{
if ($this->canBuildForm($form_state)) {
return parent::form($items, $form, $form_state, $get_delta);
}
return [];
}
示例3: form
/**
* {@inheritdoc}
*/
public function form(FieldItemListInterface $items, array &$form, FormStateInterface $form_state, $get_delta = NULL)
{
$parents = $form['#parents'];
// Identify the manage field settings default value form.
if (in_array('default_value_input', $parents, TRUE)) {
// Since the entity is not reusable neither cloneable, having a default
// value is not supported.
return ['#markup' => $this->t('No widget available for: %label.', ['%label' => $items->getFieldDefinition()->getLabel()])];
}
return parent::form($items, $form, $form_state, $get_delta);
}