N°1986 Portal: Forms with only transition buttons are now read-only

This commit is contained in:
Stephen Abello
2019-11-05 12:16:45 +01:00
parent 7c773991e7
commit da5ccaaa85
2 changed files with 33 additions and 2 deletions

View File

@@ -82,7 +82,9 @@ class ObjectFormManager extends FormManager
protected $aFormProperties;
/** @var array $aCallbackUrls */
protected $aCallbackUrls = array();
/** @var boolean $bIsSubmittable */
protected $bIsSubmittable = true;
/**
* Creates an instance of \Combodo\iTop\Portal\Form\ObjectFormManager from JSON data that must contain at least :
* - formobject_class : The class of the object that is being edited/viewed
@@ -227,7 +229,29 @@ class ObjectFormManager extends FormManager
return $this;
}
/**
*
* @return string
*/
public function GetIsSubmittable()
{
return $this->bIsSubmittable;
}
/**
*
* @param boolean $bIsSubmittable
*
* @return \Combodo\iTop\Portal\Form\ObjectFormManager
*/
public function SetIsSubmittable($bIsSubmittable)
{
$this->bIsSubmittable = $bIsSubmittable;
return $this;
}
/**
*
* @return string
@@ -461,6 +485,12 @@ class ObjectFormManager extends FormManager
}
continue;
}
// If a form can't be submitted to update an object, we have no reason to allow fields to be editable
if (!$this->GetIsSubmittable())
{
$sFieldFlags .= ' read_only';
}
// Otherwise we proceed as usual
foreach (explode(' ', $sFieldFlags) as $sFieldFlag)

View File

@@ -246,7 +246,8 @@ class ObjectFormHandlerHelper
->SetMode($sMode)
->SetActionRulesToken($sActionRulesToken)
->SetRenderer($oFormRenderer)
->SetFormProperties($aFormProperties);
->SetFormProperties($aFormProperties)
->SetIsSubmittable(isset($aFormData['buttons']['submit']));
$oFormManager->Build();