Hot answers tagged

8 votes
Accepted

How to get module parameters inside helper function and how to get params inside a custom form field type?

1. How to get Modules parameters inside Helper Function You are going all wrong with this. First, you can't use $this inside a static method, because they are independent of any instantiated object. ...
FFrewin's user avatar
  • 19.7k
7 votes

How to get module parameters inside helper function and how to get params inside a custom form field type?

I much prefer going for the OOP approach. This is what I use in one of my extensions. It's Ajax based so I have a separate function to get the parameters. helper.php: class ModSomethingHelper { ...
Lodder's user avatar
  • 26.9k
5 votes
Accepted

How to retrieve values of all the fields with JInput but without jform[]

Yes, you can get the form values without jform. Following is the approach: $data = $jinput->post : returns all post data $something = $jinput->post->get('something', 'default_value', '...
Liz.'s user avatar
  • 1,385
4 votes

Adding Custom Fields to Article Component [Not in attribs field]

I've been using FieldsAttach for this sort of thing, for a few years, the the concepts are clean and eloquent. Brian Teeman explains it well from an integrator point of view in his talk at https://www....
AndyGaskell's user avatar
4 votes
Accepted

JFormFieldList in Frontend -> Notice: Array to string conversion

I think you want to use use getOptions(..) not getInput(...) with a JFormFieldList. getInput returns the full <select /> input as a string. getOptions populates the select options with an array ...
David Hayes's user avatar
4 votes

How to use a custom layout with JForm subform fields?

Edited to add subform field type-specific answer: Having looked at it properly, attaching your own layout to the subform field type is super-easy. Create a layouts folder in the same parent ...
Bathmat's user avatar
  • 492
4 votes

How to get module parameters inside helper function and how to get params inside a custom form field type?

Your main module file and template file will have $params variable created by Joomla! core. If you have static methods, then pass that variable to function call: class ModTestHelper { public ...
Rene Korss's user avatar
  • 3,208
3 votes
Accepted

Where can I find a good tutorial and/or example for creating front-end forms in custom components?

Everything you need to get started with JForm for views https://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/
Walt Sorensen's user avatar
3 votes

Custom 'dynamic' form field creation

I am using the following to achieve something similar to what you need BUT in a plugin. Need to confirm if it is also valid to component. <field name="list_field_name" ...
n.h.'s user avatar
  • 871
3 votes

Insert value to custom field using getForm (setFieldAttribute)

Mea culpa, I had to add the name of the group: $form->setFieldAttribute('test', 'country', 'US', 'personal');
MyFault's user avatar
  • 677
3 votes
Accepted

Manually render filter form fields in layout

Include group name as the second parameter in renderField(), e.g.: echo $this->filterForm->renderField('published', 'filter'); echo $this->filterForm->renderField('limit', 'list'); Or if ...
Sharky's user avatar
  • 11.1k
3 votes
Accepted

Client side validation - custom event handler not called when user enters the field and leaves it being empty

I deleted my earlier answer, since it was on some points true but not exactly answered the question. My mind was blurred by the question. :) The question is very tricky. Why? Because in the question ...
Zollie's user avatar
  • 2,926
3 votes
Accepted

Dynamically add option to Jform field

You're already aware of Joomla\CMS\Form\Field\ListField::addOption() method. value is an attribute in the XML so it needs to be passed along with other attributes in the second argument: $this->...
Sharky's user avatar
  • 11.1k
2 votes

How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?

You can create another Registration controller and override the register() behavior. <?php class UsersControllerRegistration2 extends UsersController { public function register() { ...
quokka-web's user avatar
2 votes

How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?

Let me start by saying I do not condone this method, the next time you update Joomla there is a high probability you will undo these changes completely. This is however a working method to do what ...
Terry Carter's user avatar
  • 1,812
2 votes
Accepted

How to add attribute to <form> of backend for module

The short answer is there's an "easier" way. The assumption being you need to provide a means for a user to upload a file as part of the core configuration of the module. Since there isn't a ...
Brian Bolli's user avatar
  • 1,416
2 votes

Show Form Field if AJAX-response is false

Well you could attach your hide/show functions within the success parameter of the ajax method. var showMethod = function () { // show method code... } var hideMethod = function () { // hide ...
FFrewin's user avatar
  • 19.7k
2 votes
Accepted

How to use a custom layout with JForm subform fields?

To place a subform (Joomla! 3.6+) within another "master" form and use a custom layout: 1) In the master JForm XML file use the subform field type. <field name= "fieldname" description= "...
nimble's user avatar
  • 418
2 votes
Accepted

How to select predefined options in an custom form list-field?

I had to do the same thing. I copied the list form field code and changed it accordingly, so I have 2 functions: getInput() getOptions() which you have In the getInput function, that's what actually ...
Alex Mehan's user avatar
2 votes

Custom fields "on demand"

If you have used jform then You can use Subform field. Read here more about Subform repeatable field
Sudhir Sapkal's user avatar
2 votes
Accepted

Why does Joomla remove html tags from submitted text even when filter types are set to raw?

Using $_POST as array key in getArray() argument is producing a warning: Warning: Illegal offset type If your form is using form control (normally jform), you can get unfiltered data like this: $...
Sharky's user avatar
  • 11.1k
2 votes
Accepted

How to submit JForm form based on custom dropdown list value change

onchange attribute can be added to the fields in your XML form. E.g. this is used in filter forms: <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description=...
Sharky's user avatar
  • 11.1k
2 votes

Dynamically removing single JForm option

The small problem with your question is that <option> is not a field attribute but an element in XML, so you cannot set or remove that using methods for field attributes. You can remove however ...
Zollie's user avatar
  • 2,926
2 votes

Dynamically removing single JForm option

So this is what I've done: protected function preprocessForm(JForm $form, $data, $group = '') { $app = JFactory::getApplication(); ... if ($app->isClient('site')) { // ...
Mike's user avatar
  • 341
2 votes

Dynamically removing single JForm option

Another option could be to place the two versions of the field in separate .xml files in your /forms folder and then decide which one to load. If ($option == 1) { $form->loadFile('...
Irata's user avatar
  • 3,822
2 votes
Accepted

enable Selected option for a custom field extending JFormFieldList

If you're extending JFormFieldList then you don't need to use JHtml::_('select...) as well. Instead you just return an array of text/value combinations for the options of the HTML select. You can ...
Robbie Jackson's user avatar
2 votes
Accepted

custom form list field add disabled options - create optgroups

My question could be solved by the comments of mickmackusa and Sharky. I have finally extended the JFormFieldGroupedList as follows: defined('JPATH_PLATFORM') or die; JFormHelper::loadFieldClass('...
Marco's user avatar
  • 617
2 votes

Override module XML form displays correctly but does not save data. Why?

There's a quirk when using onContentPrepareForm event. Data may not always be available and sometimes it can be an array instead of an object. You can confirm this by inspecting PHP error log. You ...
Sharky's user avatar
  • 11.1k
2 votes

Form-Fields-Fieldset-showon issue

showon indeed works only within the same fieldset. The javascript related with the showon, can handle fields from different groups/fieldsets. The problem resides in the php logic of the FormField ...
Sakis's user avatar
  • 161
1 vote

Custom 'dynamic' form field creation

From my experience. onshow ONLY works if you use renderFieldSet if you use renderField it won't work. it seems that the whole fieldset needs to be shown at the same time so that JForm can link the ...
rob joyce's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible