public function render(array $data, \Cake\View\Form\ContextInterface $context)
 {
     $values = [];
     if ($context->val('languages')) {
         foreach ($context->val('languages') as $language) {
             if (is_object($language)) {
                 $values[] = $language->id;
             } else {
                 $values[] = $language;
             }
         }
         $data['val'] = $values;
     }
     $data['type'] = 'select';
     return parent::render($data, $context);
 }
Example #2
0
 /**
  * Create the URL for a form based on the options.
  *
  * @param \Cake\View\Form\ContextInterface $context The context object to use.
  * @param array $options An array of options from create()
  * @return string The action attribute for the form.
  */
 protected function _formUrl($context, $options)
 {
     if ($options['action'] === null && $options['url'] === null) {
         return $this->request->here(false);
     }
     if (is_string($options['url']) || is_array($options['url']) && isset($options['url']['_name'])) {
         return $options['url'];
     }
     if (isset($options['action']) && empty($options['url']['action'])) {
         $options['url']['action'] = $options['action'];
     }
     $actionDefaults = ['plugin' => $this->plugin, 'controller' => $this->request->params['controller'], 'action' => $this->request->params['action']];
     $action = (array) $options['url'] + $actionDefaults;
     $pk = $context->primaryKey();
     if (count($pk)) {
         $id = $context->val($pk[0]);
     }
     if (empty($action[0]) && isset($id)) {
         $action[0] = $id;
     }
     return $action;
 }