Re: How to make custom field as read only

  • andysong
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 2 months ago #7019 by andysong
How to make custom field as read only was created by andysong
Tuan,

is there way to make read only custom field?

Thanks always,

David Song

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

More
13 years 2 months ago #7097 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to make custom field as read only
Hi David

Do you want to use the custom fields to display on events list and event detail page or the custom fields to display on registration form ?

Please give me more detail information so that I can guide you .

Thanks,

Tuan

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

  • andysong
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 2 months ago #7137 by andysong
Replied by andysong on topic Re: How to make custom field as read only
Yes, I want put custom field as read only field in registration form.

Thanks!

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

More
13 years 2 months ago #7152 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to make custom field as read only
Hi David

In this case, I think you can create a custom field, type Message . It will display a message on the form .

Hope it will be Ok for you

Thanks,

Tuan

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

  • andysong
  • Topic Author
  • Offline
  • New Member
  • New Member
More
13 years 2 months ago #7169 by andysong
Replied by andysong on topic Re: How to make custom field as read only
Thank you for your prompt reply.
Unfortunately, your suggestion didn't work for me. What I'm trying to do is to create a custom "fee" field that user can only see but not changing it. when I set the field type as Message, it is no longer "fee" field.
is there any way to make custom field "read only" or "disabled"?

Thanks,

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

More
13 years 2 months ago #7246 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to make custom field as read only
Hi David

It is not available in the current version. However, I think you can do it with a small hack into the extension. The file you will need to modify is components/com_eventbooking/helper/fields.php, look at line 127 : (under _renderTextBox($row) function)

Code:
<input type="text" name="<?php echo $row->name ; ?>" class="<?php echo $row->css_class; ?>" size="<?php echo $row->size ; ?>" value="<?php echo $postedValue ; ?>" />

Change it to :
Code:
<input type="text" name="<?php echo $row->name ; ?>" class="<?php echo $row->css_class; ?>" size="<?php echo $row->size ; ?>" value="<?php echo $postedValue ; ?>" <?php $row->name == 'NAME_OF_THE_FIELD' ? ' readonly="readonly"' : '' ;?> />

The idea is that if the custom field name is NAME_OF_THE_FIELD (you need to replace with a correctly name), we will add readonly property to the custom field so that registrants cannot change it.

Hope this will give an idea. If you know PHP code , this will be easy to modify .

Thanks,

Tuan

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

More
3 years 1 month ago #141878 by Frank
Replied by Frank on topic Re: How to make custom field as read only
Hi Tuan.

Is this hack still available, I really need to turn one custom field to Read only in front-end but admin can modify it.

I tried to locate the file components/com_eventbooking/helper/fields.php but it is not part of the component anymore. Would you please let me know where the code is located?
Thanks

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

More
3 years 1 month ago #141879 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to make custom field as read only
Hello

For latest version 2.14.2:

- Edit the custom field, look at Extra setting, enter readonly there
- Get this file, unzip it, upload to administrator/templates/isis/html/com_eventbooking/registrant folder

Then check the result. It should work

Regards,

Tuan
Attachments:

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

More
3 years 1 month ago #141888 by Frank
Replied by Frank on topic Re: How to make custom field as read only
works perfect. Thank you so much Tuan for your quick reply.

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

More
3 years 1 month ago #141890 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to make custom field as read only
You're welcome. Have a nice weekend

Tuan

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

Moderators: Tuan Pham Ngoc