/**
  * @param $varInput
  * @return mixed
  */
 protected function validator($varInput)
 {
     // Get language id
     $intId = $this->activeRecord ? $this->activeRecord->{$this->strName} : $GLOBALS['TL_CONFIG'][$this->strName];
     // Check if translation fields should not be empty saved
     if (!$GLOBALS['TL_CONFIG']['dontfillEmptyTranslationFields']) {
         // Fill all empty fields with the content of the fallback field
         $varInput = \TranslationFieldsWidgetHelper::addFallbackValueToEmptyField($varInput);
         parent::validator($varInput);
     } else {
         // Check only the first field
         parent::validator($varInput[key($varInput)]);
     }
     // Check if array
     if (is_array($varInput)) {
         if (!parent::hasErrors()) {
             // Save values and return fid
             return \TranslationFieldsWidgetHelper::saveValuesAndReturnFid($varInput, $intId);
         }
     }
     return $intId;
 }
Esempio n. 2
0
	/**
	 * Return the comment widget as object
	 * @param mixed
	 * @return Widget
	 */
	protected function getCommentWidget($value=null)
	{
		$widget = new TextArea();

		$widget->id = 'comment';
		$widget->name = 'comment';
		$widget->mandatory = true;
		$widget->decodeEntities = true;
		$widget->style = 'height:120px;';
		$widget->value = $value;

		$widget->label = $GLOBALS['TL_LANG']['tl_task']['comment'][0];

		if ($GLOBALS['TL_CONFIG']['showHelp'] && $GLOBALS['TL_LANG']['tl_task']['comment'][1] != '')
		{
			$widget->help = $GLOBALS['TL_LANG']['tl_task']['comment'][1];
		}

		// Valiate input
		if ($this->Input->post('FORM_SUBMIT') == 'tl_tasks')
		{
			$widget->validate();

			if ($widget->hasErrors())
			{
				$this->blnSave = false;
			}
		}

		return $widget;
	}