Page 1 of 1

ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 2:41 pm
by fhkvf

On some tables i use fields with "ReadOnly" ($this->product->ReadOnly = true;) and autofill.
However, since version 2024 this no longer seems to work for destination fields.

ReadOnly configuration works, but not in combination with autofill on the destination.
At the html i see only <input ... data-readonly="1" ...> but not readonly=1. Is there something special with v2024?

As Workaround i use Client Script $("#x_product").prop("readonly", true).


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 2:46 pm
by measan

try this code on clientscript :

$("#x_product").attr("readonly", "readonly");


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 2:53 pm
by measan

if you want autofill just do

Select field and then click Use lookup table - fill table name and link field and click Display Field and then click Autofill set True and click option and set field in there with Auto Fill.


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 3:11 pm
by fhkvf

Thank you measan. My workaround works also.

But i want to use it, in same way as before v2024 with $this->myFieldName->ReadOnly = true; for fields with autofill and without.
I would like to keep the config homogeneous as before.


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 4:21 pm
by mobhar

In which server event did you put that $this->myFieldName->ReadOnly = true; code?


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 6:30 pm
by fhkvf

Normaly i use Page_Load(), and try Page_Render() with same result.


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 7:32 pm
by mobhar

Try Row_Rendered server event.


Re: ReadOnly Field with Autofill

Posted: Fri Jan 12, 2024 7:54 pm
by fhkvf

Mhh.
I tried Table-Specific -> Common -> Row_Rendered, but it does not work.
i can use the input field as it is and can type any chars... there is no readonly="1" within input tag as other none autofill destination fields.

function Row_Rendered() {
	//simple test
	$this->product->ReadOnly = true;
}

Result:

<input type="text" name="x_product" id="x_product" data-table="order" data-field="x_product" value="" data-page="1" maxlength="100" placeholder="" data-format-pattern="" class="form-control disabled" data-readonly="1" aria-describedby="x_product_help">

Re: ReadOnly Field with Autofill

Posted: Wed Feb 14, 2024 7:17 pm
by hakanari

Version 2024, ReadOnly does not work on Select and Multiselect Fields. The others are ok. Is there any solution to solve this problem?

    if (condition) {
        $this->text_field->ReadOnly = true; //Works
        $this->select_field->ReadOnly = true; //Does not work!
        $this->multiselect_field->ReadOnly = true; //Does not work!
    }

Re: ReadOnly Field with Autofill

Posted: Wed Feb 14, 2024 8:18 pm
by arbei

Note that readonly attribute is for text input only, you may use Disabled property instead.