Please post all pre-sales questions of all products on this forum

Default values on User Fields

  • Bill
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 10 months ago #113976 by Bill
Default values on User Fields was created by Bill
Hi Tuan,

We have elected to allow subscribers to become active members if they have indicated that they wish to pay via an electronic funds transfer (i.e. not to pay via credit card but by a direct payment to our bank account). We will check that if they haven't paid within a month, then we manually suspend their membership. This might sound crazy, but most people do actually pay.

To monitor payment I have included an indicator as a User field called "EFT-Confirmation". This is a radio button with two possible values: "Yes" or "No". I have set the default to "No". This field is not displayed to the subscriber but is there for the administrators to access either at the back end or the front end. I have also written a report that shows who hasn't paid after one month.

The problem that arises is that as new members subscribe this field is not defaulting to anything and remains empty, even though I have specified that a value is required. This field is not shown on the application form (as I don't want them to see it) so I guess the default value is not being entered by the system.

Is there a way I can ensure that this field does take on the default value?

Many thanks for your help.

Regards,

Bill

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #113977 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Default values on User Fields
Hi Bill

Unfortunately, there is no way for having it works like that. Default value will only be used when the form is first loaded (and the field has to be visible on the form)

In your case, the field is not displayed on the form, so the default value won't be used

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Bill
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 10 months ago #113989 by Bill
Replied by Bill on topic Default values on User Fields
Hi Tuan,

Thanks for the reply.

Ok. Do you have any ideas on how I could implement this method of payment? Bit of a long shot, I know. :-)

Regards,

Bill

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #113991 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Default values on User Fields
Hi Bill

I could not be sure but you might want to try this solution:

1. Open the file administrator/components/com_eventbooking/libraries/rad/form/form.php

2. Find the method public function bind($data, $useDefault = false)

3. Replace the code of that method with this code:
Code:
public function bind($data, $useDefault = false) { foreach ($this->fields as $field) { if (isset($data[$field->name])) { $field->setValue($data[$field->name]); } else { if ($field->type == 'Checkboxes' || ($field->type == 'List' && $field->row->multiple)) { $field->setValue(explode("\r\n", $field->row->default_values)); } else { $field->setValue($field->row->default_values); } } } return $this; }

After that, check it again. It might work as expected

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Bill
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
5 years 10 months ago #114076 by Bill
Replied by Bill on topic Default values on User Fields
Hi Tuan,

Many thanks, but I think that code is for event booking application and not os_membershippro. Instead I think I have found that file under:
administrator/components/com_osmembership/libraries/form but there is no mention of $field->type == 'Checkboxes' or 'List' so I have come to a full stop.

However, I realised that I can solve my problem by changing the field type to a checkbox. This automatically has a default of 'false' and there is only one other state and that is 'true' which I represent as "paid". So all is sorted.

Thanks for your help anyway.

Regards,

Bill

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #114092 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Default values on User Fields
OK Bill. That's great. Avoid modifying core code is better as it allows you to update to future releases of the extension without having to worry about loosing the modification

Regards,

Tuan

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham NgocGiang Dinh TruongMr. Dam