/**
  * Initialize arguments.
  *
  * @return void
  */
 public function initializeArguments()
 {
     parent::initializeArguments();
     $this->registerArgument('repository', 'string', 'Specifies the tree repository', false);
     $this->registerArgument('namespace', 'string', 'Specifies the tree namespace', false);
     $this->registerArgument('type', 'string', 'Specifies the tree type', false);
     $this->registerArgument('respectEnableFields', 'boolean', 'Should the tree respect enable fields', false);
     $this->registerArgument('moduleName', 'string', 'Specify the module name', false);
 }
 /**
  * Get the value of this form element (changed to prefill from TypoScript)
  * Either returns arguments['value'], or the correct value for Object Access.
  *
  * @return mixed Value
  */
 protected function getValue($convertObjects = true)
 {
     $value = parent::getValue($convertObjects);
     // prefill value from TypoScript
     if (empty($value) && $this->getValueFromTypoScript()) {
         $value = $this->getValueFromTypoScript();
     }
     return $value;
 }
Exemple #3
0
 /**
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     $doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $doc->backPath = $GLOBALS['BACK_PATH'];
     $pageRenderer = $doc->getPageRenderer();
     $pageRenderer->loadExtJS();
     $pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/tceforms.js');
     $typo3Settings = array('datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0, 'dateFormat' => array('j-n-Y', 'j-n-Y'), 'dateFormatUS' => array('n-j-Y', 'n-j-Y'));
     $pageRenderer->addInlineSettingArray('', $typo3Settings);
 }
 /**
  * @test
  */
 public function renderCorrectlySetsRequiredAttribute()
 {
     $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('addAttribute', 'setContent', 'render'), array(), '', false);
     $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('type', 'text');
     $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'NameOfTextfield');
     $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('NameOfTextfield');
     $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('value', 'Current value');
     $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('required', 'required');
     $mockTagBuilder->expects($this->once())->method('render');
     $this->viewHelper->_set('tag', $mockTagBuilder);
     $arguments = array('name' => 'NameOfTextfield', 'value' => 'Current value');
     $this->viewHelper->setArguments($arguments);
     $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
     $this->viewHelper->initialize();
     $this->viewHelper->render(true);
 }
 /**
  * @test
  */
 public function renderAddsPlaceholder()
 {
     $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('addAttribute', 'setContent', 'render'), array(), '', FALSE);
     $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('placeholder', 'SomePlaceholder');
     $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'text');
     $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'NameOfTextfield');
     $mockTagBuilder->expects($this->once())->method('render');
     $this->viewHelper->_set('tag', $mockTagBuilder);
     $arguments = array('name' => 'NameOfTextfield', 'placeholder' => 'SomePlaceholder');
     $this->viewHelper->setArguments($arguments);
     $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
     $this->viewHelper->initialize();
     $this->viewHelper->render();
 }
    /**
     * @param boolean $required If the field is required or not
     * @param string $type The field type, e.g. "text", "email", "url" etc.
     * @param integer $sliderMin
     * @param integer $sliderMax
     * @param integer $sliderStep
     *
     * @return string
     */
    public function render($required = null, $type = 'text', $sliderMin = 0, $sliderMax = 10, $sliderStep = 1)
    {
        $inputString = parent::render($required, $type);
        $id = $this->arguments['id'];
        if (empty($id)) {
            return 'Please add an id to the slider';
        }
        $value = $sliderMin;
        if ($this->getValue() > $value) {
            $value = $this->getValue();
        }
        $sliderElementTemplate = '<div class="slider-element-wrap">%s<div class="slider-bar-wrap"><div class="slider-element" id="slider-' . $id . '"></div></div><div class="slider-input-wrap">%s</div></div>';
        $javascriptCode = '<script type="text/javascript">
$(function() {
	if (jQuery.ui) {
		jQuery("#slider-' . $id . '").slider({
			range: "min",
			min: ' . $sliderMin . ',
			max: ' . $sliderMax . ',
			step: ' . $sliderStep . ',
			value: ' . $value . ',
			slide: function(event, ui) {
				jQuery(ui.handle).closest(".slider-element-wrap").find("input").val(ui.value);
			}
		});

		jQuery("#' . $id . '").val(' . $value . ').live("keyup", function() {
			if (' . $sliderMin . ' <= this.value && this.value <= ' . $sliderMax . ') {
				jQuery(this).closest(".slider-element-wrap").find(".slider-element").slider("value", this.value);
			}
		});
	}
});
</script>';
        return sprintf($sliderElementTemplate, $javascriptCode, $inputString);
    }
 /**
  * Renders the treeSelector.
  *
  * @param boolean $required If the field is required or not
  * @return string
  * @api
  */
 public function render($required = null)
 {
     $formField = parent::render($required, 'hidden', null);
     if (!$this->nodes) {
         $this->nodes = $this->getTreeNodes();
     }
     $treeDiv = $this->getTreeDiv();
     $treeJS = $this->getTreeJS($this->nodes);
     return $formField . $treeDiv . $treeJS;
 }