AbanteCart Community

eCommerce construction => How-to questions => Topic started by: shahiran12395 on July 17, 2019, 12:27:09 AM

Title: readonly input
Post by: shahiran12395 on July 17, 2019, 12:27:09 AM
hi guys. i want to create readonly or disable input attribute. how can i set it? i try adding 'readonly'=>true in each form array but not working

Code: [Select]
$this->data['form']['fields']['general']['phone_code'] = $form->getFieldHtml(
            array (
                'type'  => 'input',
                'name'  => 'phone_code',
                'value' => $phone_code,
                'readonly' => true
            ));
Title: Re: readonly input
Post by: Basara on July 17, 2019, 01:07:37 AM
Hello.

Try "disabled"
Title: Re: readonly input
Post by: shahiran12395 on July 17, 2019, 01:26:05 AM
i have try it but i can still insert any value into the field. the value will be assign by js function that i have create so it doesn't need any customer input.
Title: Re: readonly input
Post by: Basara on July 17, 2019, 01:43:56 AM
In that case try hidden input
Title: Re: readonly input
Post by: shahiran12395 on July 17, 2019, 02:09:15 AM
is this the right way to set it? cause i still the same

Code: [Select]
$this->data['form']['fields']['general']['phonecode'] = $form->getFieldHtml(
            array (
                'type'  => 'input',
                'name'  => 'phonecode',
                'value' => $phonecode,
                'hidden' => true
            ));
Title: Re: readonly input
Post by: Basara on July 17, 2019, 02:11:41 AM
I think you should check how core engine build elements to get idea about correct values
For example https://github.com/abantecart/abantecart-src/blob/master/public_html/core/engine/html.php#L720
Title: Re: readonly input
Post by: shahiran12395 on July 17, 2019, 02:37:02 AM
thanks..it help.. i just figure out how to make the input readonly. btw how can i display the label for the input? i cant display the label for my new input