Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: readonly input  (Read 3110 times)

Offline shahiran12395

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +3/-0
    • View Profile
readonly input
« 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
            ));

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: readonly input
« Reply #1 on: July 17, 2019, 01:07:37 AM »
Hello.

Try "disabled"

Offline shahiran12395

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +3/-0
    • View Profile
Re: readonly input
« Reply #2 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.

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: readonly input
« Reply #3 on: July 17, 2019, 01:43:56 AM »
In that case try hidden input

Offline shahiran12395

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +3/-0
    • View Profile
Re: readonly input
« Reply #4 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
            ));

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: readonly input
« Reply #5 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

Offline shahiran12395

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +3/-0
    • View Profile
Re: readonly input
« Reply #6 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

 

Powered by SMFPacks Social Login Mod