Create template overrides for com_contact
.
Go to /templates/yourtheme/com_contact/contact/default_form.php
Try to update field attribute by putting after this:
<?php foreach ($fields as $field) : ?>
following code:
/* @var $field FormField */
$name = $field->getAttribute('name');
$this->form->setFieldAttribute($name, 'hint', $field->getAttribute('label'));
Now create new contact and create a new menu item for it.
Go to front end and look at the message form.
Each text field should have a placeholder
attribute same as field label (the code above just uses field label to set text field placeholder).
Nothing changes.
Joomla 3.8.12
It looks like on the way to view form fields lose reference. That way it is impossible to update field attributes from inside the view. It leads to dirty workarounds like str_ireplace etc. It worked previously but I'm not sure in which version it started failing. There is still possibility to override form fields layouts for com_contact but that feels like overkill for simple attribute change.
Status | New | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-29 03:28:26 |
Closed_By | ⇒ | Quy |
Closed_Date | 2018-12-29 03:28:26 | ⇒ | 2018-12-29 03:28:27 |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/22115
Ok 1 way of achieve setting the attribute (as mentioned by @SharkyKZ) are
$this->form->setFieldAttribute($field->fieldname, 'hint', $field->getAttribute('label'));
echo $this->form->renderField($field->fieldname, $field->group);
Another way (instead of str_replace) is to do
$field->__set('hint', $field->getAttribute('label'));
echo $field->renderField();
but why some place are using
$this->form->renderField('somefieldname');
and other are using
$field->renderField() ?
why not use everywhere ?
$this->form->renderField($field->fieldname, $field->group);
Comment above by @SharkyKZ isn't shown in issue Tracker.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/22115.