Exemplo n.º 1
0
 /**
  * Input TinyMCE text area.
  *
  * @param string $fieldName
  * @param array $options
  * @return string
  */
 public function input($fieldName, array $options = [])
 {
     $this->assets();
     $id = uniqid('tiny-mce-');
     $_options = ['id' => $id, 'isAdmin' => false, 'preset' => 'default', 'type' => 'textarea', 'class' => ['input', 'textarea', 'jsTinyMce']];
     $options = Hash::merge($_options, $options);
     $isAdmin = $options['isAdmin'];
     if ($isAdmin) {
         $options['preset'] = 'full';
     }
     $preset = $options['preset'];
     unset($options['isAdmin']);
     unset($options['preset']);
     $this->_tinyInit($id, $preset, $isAdmin);
     $this->_View->Form->unlockField($fieldName);
     return parent::input($fieldName, $options);
 }
Exemplo n.º 2
0
 /**
  * Simple test for textarea html element.
  *
  * @return void
  */
 public function testTextArea()
 {
     $actual = $this->Form->input('test', ['type' => 'textarea']);
     $expected = ['div' => ['class' => 'un-input form-group field-test un-textarea'], 'label' => ['for' => 'test'], 'Test', '/label', 'textarea' => ['name' => 'test', 'rows' => 15, 'class' => 'form-control', 'id' => 'test'], '/textarea', '/div'];
     $this->assertHtml($expected, $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $actual = $this->Form->input('test', ['type' => 'textarea', 'class' => 'custom-class', 'id' => 'my-id']);
     $expected = ['div' => ['class' => 'un-input form-group field-test un-textarea'], 'label' => ['for' => 'my-id'], 'Test', '/label', 'textarea' => ['name' => 'test', 'rows' => 15, 'class' => 'custom-class form-control', 'id' => 'my-id'], '/textarea', '/div'];
     $this->assertHtml($expected, $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $actual = $this->Form->textarea('test');
     $expected = ['textarea' => ['name' => 'test', 'rows' => 15, 'class' => 'form-control'], '/textarea'];
     $this->assertHtml($expected, $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $actual = $this->Form->textarea('test', ['class' => 'custom-class', 'id' => 'my-id']);
     $expected = ['textarea' => ['name' => 'test', 'rows' => 15, 'class' => 'custom-class form-control', 'id' => 'my-id'], '/textarea'];
     $this->assertHtml($expected, $actual);
 }
Exemplo n.º 3
0
 /**
  * Initialize helper.
  *
  * @param array $config
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
     $this->_controller = $this->request->param('controller');
 }