Render fields only if visible

This commit is contained in:
Giuseppe Criscione 2019-09-23 21:46:28 +02:00
parent 15a64d38b8
commit c1281bafc6
2 changed files with 13 additions and 1 deletions

View File

@ -163,7 +163,9 @@ abstract class AbstractController
*/
protected function field(Field $field, $render = true)
{
return $this->view('fields.' . $field->type(), array('field' => $field), $render);
if ($field->isVisible()) {
return $this->view('fields.' . $field->type(), array('field' => $field), $render);
}
}
/**

View File

@ -105,6 +105,16 @@ class Field extends DataSetter
return $this->get('value', $this->get('default'));
}
/**
* Return whether the field is visible
*
* @return bool
*/
public function isVisible()
{
return $this->get('visible', true) === true;
}
/**
* Import data helper
*/