/**
  * Overrides Drupal\Core\Entity\EntityFormController::form().
  */
 public function form(array $form, array &$form_state, EntityInterface $font)
 {
     $provider = fontyourface_provider_load($font->bundle());
     $form_state['fontyourface']['provider'] = $provider;
     // Add any form fields that don't map to entity fields here.
     /*
     $form['name'] = array(
           '#type' => 'textfield',
           '#title' => t('Name'),
           '#default_value' => $term->name,
           '#maxlength' => 255,
           '#required' => TRUE,
           '#weight' => -5,
         );
     
         $form['description'] = array(
           '#type' => 'text_format',
           '#title' => t('Description'),
           '#default_value' => $term->description,
           '#format' => $term->format,
           '#weight' => 0,
         );
         $language_configuration = module_invoke('language', 'get_default_configuration', 'taxonomy_term', $vocabulary->id());
         $form['langcode'] = array(
           '#type' => 'language_select',
           '#title' => t('Language'),
           '#languages' => LANGUAGE_ALL,
           '#default_value' => $term->langcode,
           '#access' => !is_null($language_configuration['language_show']) && $language_configuration['language_show'],
         );
     
         $form['relations'] = array(
           '#type' => 'details',
           '#title' => t('Relations'),
           '#collapsed' => ($vocabulary->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE),
           '#weight' => 10,
         );
     */
     $form['pid'] = array('#type' => 'value', '#value' => $provider->id());
     $form['fid'] = array('#type' => 'value', '#value' => $font->fid);
     if (empty($font->fid)) {
         $form_state['redirect'] = current_path();
     }
     // if
     return parent::form($form, $form_state, $font);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, array &$form_state)
 {
     $form['#tree'] = TRUE;
     $form['#attached']['css'][] = drupal_get_path('module', 'feeds') . '/feeds.css';
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('Edit %label', array('%label' => $this->entity->label()));
     }
     $form['basics'] = array('#title' => $this->t('Basic settings'), '#type' => 'details', '#tree' => FALSE, '#collapsed' => !$this->entity->isNew());
     $form['basics']['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#default_value' => $this->entity->label(), '#maxlength' => '255', '#description' => $this->t('A unique label for this importer. This label will be displayed in the interface.'));
     $form['basics']['id'] = array('#type' => 'machine_name', '#title' => $this->t('Machine name'), '#default_value' => $this->entity->id(), '#disabled' => !$this->entity->isNew(), '#maxlength' => 64, '#description' => $this->t('A unique name for this importer. It must only contain lowercase letters, numbers and underscores.'), '#machine_name' => array('exists' => array($this, 'exists'), 'source' => array('basics', 'label')));
     $form['basics']['description'] = array('#type' => 'textfield', '#title' => $this->t('Description'), '#description' => $this->t('A description of this importer.'), '#default_value' => $this->entity->description);
     $form['plugin_settings'] = array('#type' => 'vertical_tabs', '#weight' => 99);
     $form['plugin_settings']['#prefix'] = '<div id="feeds-ajax-form-wrapper" class="theme-settings-bottom">';
     $form['plugin_settings']['#suffix'] = '</div>';
     // If this is an ajax requst, updating the plugins on the importer will give
     // us the updated form.
     if (isset($form_state['values'])) {
         if ($form_state['values']['processor']['id'] != $this->entity->getProcessor()->getPluginId()) {
             $this->entity->removeMappings();
         }
         foreach ($this->entity->getPluginTypes() as $type) {
             $this->entity->setPlugin($type, $form_state['values'][$type]['id']);
         }
     }
     foreach ($this->entity->getPlugins() as $type => $plugin) {
         $options = $this->entity->getPluginOptionsList($type);
         $form[$type] = array('#type' => 'container', '#attributes' => array('class' => array('feeds-plugin-inline')));
         if (count($options) === 1) {
             $form[$type]['id'] = array('#type' => 'value', '#value' => $plugin->getPluginId(), '#plugin_type' => $type);
         } else {
             $form[$type]['id'] = array('#type' => 'select', '#title' => $this->t('@type', array('@type' => ucfirst($type))), '#options' => $options, '#default_value' => $plugin->getPluginId(), '#ajax' => array('callback' => array($this, 'ajaxCallback'), 'wrapper' => 'feeds-ajax-form-wrapper', 'effect' => 'none', 'progress' => 'none'), '#attached' => array('library' => array(array('feeds', 'feeds'))), '#plugin_type' => $type);
         }
         // Give lockable plugins a chance to lock themselves.
         // @see \Drupal\feeds\Feeds\Processor\EntityProcessor::isLocked()
         if ($plugin instanceof LockableInterface) {
             $form[$type]['id']['#disabled'] = $plugin->isLocked();
         }
         // This is the small form that appears under the select box.
         if ($plugin instanceof AdvancedFormPluginInterface) {
             $form[$type]['advanced'] = $plugin->buildAdvancedForm(array(), $form_state);
         }
         $form[$type]['advanced']['#prefix'] = '<div id="feeds-plugin-' . $type . '-advanced">';
         $form[$type]['advanced']['#suffix'] = '</div>';
         if ($plugin instanceof PluginFormInterface) {
             if ($plugin_form = $plugin->buildConfigurationForm(array(), $form_state)) {
                 $form[$type . '_configuration'] = array('#type' => 'details', '#group' => 'plugin_settings', '#title' => $this->t('@type settings', array('@type' => ucfirst($type))), '#parents' => array($type, 'configuration'));
                 // $form[$type . '_configuration']['#prefix'] = '<span id="feeds-' . $type . '-details">';
                 // $form[$type . '_configuration']['#suffix'] = '</span>';
                 $form[$type . '_configuration'] += $plugin_form;
             }
         }
     }
     return parent::form($form, $form_state);
 }