Example #1
0
 /**
  * Generate inputs in all locales.
  *
  * @param \Cake\ORM\Entity $entity The entity that was fired.
  * @param string $field The field to process.
  * @param array $options The options to pass to the input.
  * @param string $divClass The class to set to the div before the input.
  * @param string $id The id of the input.
  *
  * @return string
  */
 public function i18nInput(Entity $entity, $field, $options = [], $divClass = 'col-sm-5', $id = 'CkEditorBox')
 {
     $html = '';
     $CkEditor = isset($options['CkEditor']) ? $options['CkEditor'] : false;
     $i = 0;
     foreach ($this->_locales as $locale => $lang) {
         if ($locale == Configure::read('I18n.locale')) {
             continue;
         }
         $i++;
         $translationOption = $options;
         $translationOption['label'] = Inflector::humanize($lang);
         $translationOption['value'] = $entity->translation($locale)->{$field};
         if (isset($options['CkEditor']) && $options['CkEditor'] == true) {
             $translationOption['id'] = $id . '-' . $i;
         }
         $html .= '<div class="form-group">';
         $html .= '<div class="col-sm-offset-2 ' . $divClass . '">';
         $html .= $this->Form->input('translations.' . $locale . '.' . $field, $translationOption);
         $html .= '</div></div>';
     }
     return $html;
 }