* ( 1 for contact summary.
* top bar form and 2 for display name edit )
*/
- public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
+ public static function buildQuickForm($form, $inlineEditMode = NULL): void {
+ $form->addOptionalQuickFormElement('formal_title');
$form->applyFilter('__ALL__', 'trim');
if (!$inlineEditMode || $inlineEditMode == 1) {
// Fixme: dear god why? these come out in a format that is NOT the name of the fields.
foreach ($nameFields as &$fix) {
$fix = str_replace(' ', '_', strtolower($fix));
- if ($fix == 'prefix' || $fix == 'suffix') {
+ if ($fix === 'prefix' || $fix === 'suffix') {
// God, why god?
$fix .= '_id';
}
}
/**
- * Get any smarty elements that may not be present in the form.
+ * Quick form elements which are conditionally added to the form.
+ *
+ * Elements in this array will be added to the form at the end if not present
+ * so that smarty does not e-notice on things like '{if $form.group}' when
+ * 'group' is not added to the form (e.g when no groups exist).
+ *
+ * @var array
+ */
+ protected $optionalQuickFormElements = [];
+
+ /**
+ * Add an optional element to the optional elements array.
+ *
+ * @param string $elementName
+ */
+ public function addOptionalQuickFormElement(string $elementName): void {
+ $this->optionalQuickFormElements[] = $elementName;
+ }
+
+ /**
+ * Get any quick-form elements that may not be present in the form.
*
* To make life simpler for smarty we ensure they are set to null
* rather than unset. This is done at the last minute when $this
* @return array
*/
public function getOptionalQuickFormElements(): array {
- return [];
+ return $this->optionalQuickFormElements;
}
/**