mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
N°1986 Portal: Forms with only transition buttons are now read-only
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -246,7 +246,8 @@ class ObjectFormHandlerHelper
|
||||
->SetMode($sMode)
|
||||
->SetActionRulesToken($sActionRulesToken)
|
||||
->SetRenderer($oFormRenderer)
|
||||
->SetFormProperties($aFormProperties);
|
||||
->SetFormProperties($aFormProperties)
|
||||
->SetIsSubmittable(isset($aFormData['buttons']['submit']));
|
||||
|
||||
$oFormManager->Build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user