Issue #2486999 by metzlerd, er.pushpinderrana, jhodgdon: Create Documentation For Button Form Elements

8.0.x
Alex Pott 2015-10-19 16:58:46 -07:00
parent af97e790f3
commit 78aba37b6f
4 changed files with 65 additions and 0 deletions

View File

@ -16,6 +16,23 @@ use Drupal\Core\Render\Element;
* When the button is pressed, the form will be submitted to Drupal, where it is * When the button is pressed, the form will be submitted to Drupal, where it is
* validated and rebuilt. The submit handler is not invoked. * validated and rebuilt. The submit handler is not invoked.
* *
* Properties:
* - #limit_validation_errors: An array of form element keys that will block
* form submission when validation for these elements or any child elements
* fails. Specify an empty array to suppress all form validation errors.
* - #value: The text to be shown on the button.
*
*
* Usage Example:
* @code
* $form['actions']['preview'] = array(
* '#type' => 'button',
* '#value => $this->t('Preview'),
* );
* @endcode
*
* @see \Drupal\Core\Render\Element\Submit
*
* @FormElement("button") * @FormElement("button")
*/ */
class Button extends FormElement { class Button extends FormElement {

View File

@ -10,6 +10,36 @@ namespace Drupal\Core\Render\Element;
/** /**
* Provides a render element for a set of links rendered as a drop-down button. * Provides a render element for a set of links rendered as a drop-down button.
* *
* By default, this element sets #theme so that the 'links' theme hook is used
* for rendering, with suffixes so that themes can override this specifically
* without overriding all links theming. If the #subtype property is provided in
* your render array with value 'foo', #theme is set to links__dropbutton__foo;
* if not, it's links__dropbutton; both of these can be overridden by setting
* the #theme property in your render array. See template_preprocess_links()
* for documentation on the other properties used in theming; for instance, use
* element property #links to provide $variables['links'] for theming.
*
* Properties:
* - #links: An array of links to actions. See template_preprocess_links() for
* documentation the properties of links in this array.
*
* Usage Example:
* @code
* $form['actions']['extra_actions'] = array(
* '#type' => 'dropbutton',
* '#links' => array(
* 'simple_form' => array(
* 'title' => $this->t('Simple Form'),
* 'url' => Url::fromRoute('fapi_example.simple_form'),
* ),
* 'demo' => array(
* 'title' => $this->t('Build Demo'),
* 'url' => Url::fromRoute('fapi_example.build_demo'),
* ),
* ),
* );
* @endcode
*
* @see \Drupal\Core\Render\Element\Operations * @see \Drupal\Core\Render\Element\Operations
* *
* @RenderElement("dropbutton") * @RenderElement("dropbutton")

View File

@ -14,6 +14,8 @@ namespace Drupal\Core\Render\Element;
* difference is that it offers themes the possibility to render it differently * difference is that it offers themes the possibility to render it differently
* through a theme suggestion. * through a theme suggestion.
* *
* @see \Drupal|Core\Render\Element\DropButton
*
* @RenderElement("operations") * @RenderElement("operations")
*/ */
class Operations extends Dropbutton { class Operations extends Dropbutton {

View File

@ -13,6 +13,22 @@ namespace Drupal\Core\Render\Element;
* Submit buttons are processed the same as regular buttons, except they trigger * Submit buttons are processed the same as regular buttons, except they trigger
* the form's submit handler. * the form's submit handler.
* *
* Properties:
* - #submit: Specifies an alternate callback for form submission when the
* submit button is pressed. Use '::methodName' format or an array containing
* the object and method name (for example, [ $this, 'methodName'] ).
* - #value: The text to be shown on the button.
*
* Usage Example:
* @code
* $form['actions']['submit'] = array(
* '#type' => 'submit,
* '#value' => $this->t('Save'),
* );
* @endcode
*
* @see \Drupal\Core\Render\Element\Button
*
* @FormElement("submit") * @FormElement("submit")
*/ */
class Submit extends Button { class Submit extends Button {