Пример #1
0
/**
 * Take a Form API array and save settings for changed elements.
 *
 * @param $form_type
 *   The type of form being loaded.
 * @param $form_id
 *   The unique identifier for the form being edited.
 */
function hook_form_builder_load($form_type, $form_id)
{
    if ($form_type == 'node') {
        $node = (object) array('type' => preg_replace('/_node_form/', '', $form_id));
        // Load the form, usually by calling it's function directly.
        $form = node_form(array(), $node);
        // Allow other modules to extend the form.
        $form_state = [];
        drupal_alter('form', $form, $form_state, $form_id);
        // Loop through the form and add #form_builder properties to each element
        // that is configurable.
        foreach (element_children($form) as $key) {
            $form[$key]['#form_builder'] = array('configurable' => TRUE, 'removable' => TRUE);
        }
        return $form;
    }
}
Пример #2
0
/**
 * Take a Form API array and save settings for changed elements.
 *
 * @param $form_type
 *   The type of form being loaded.
 * @param $form_id
 *   The unique identifier for the form being edited.
 */
function hook_form_builder_load($form_type, $form_id) {
  if ($form_type == 'node') {
    $node = (object) array(
      'type' => preg_replace('/_node_form/', '', $form_id),
    );

    // Load the form, usually by calling it's function directly.
    $form = node_form(array(), $node);

    // Allow other modules to extend the form.
    drupal_alter('form', $form, array(), $form_id);

    // Loop through the form and add #form_builder properties to each element
    // that is configurable.
    foreach (element_children($form) as $key) {
      $form[$key]['#form_builder'] = array(
        'configurable' => TRUE,
        'removable' => TRUE,
        // If unique, when this element is deleted, a new one will appear in the
        // new field pallette.
        //'unique' => TRUE,
      );
    }

    return $form;
  }
}