Hi Alejandro! I need a little help trying to change a crud generated textf

Hi Alejandro!

I need a little help trying to change a crud generated textfield’s value inside a
addValueChangeListener
the setFieldCreationListener won’t work inside it.

Example

//Inside constructor of view
    crud.getCrudFormFactory().setFieldProvider("name", () -> {
      TextField tfURL = new TextField("url");

      tfURL.addValueChangeListener(e -> {
        String urlToLook = tfURL.getValue();

        result = //fetch something;
		crud.getCrudFormFactory().setFieldCreationListener
                ("inputTochange", field -> field.setValue(resul));
      });

      return tfURL;
    });

How can I cahnge the value of an input field inside a listener of another field?

Thanks beforehand.
And great work!

The value change listener should work. Maybe the problem is that you are setting a creation listener for a field that was already created, so that part won’t get called. What you can do is define the input fields instances in an outer scope and then change the values using this instances. Something like:

var field1 = new TextField();
var field2 = new TextField();

formFactory.setFieldProvider("property1", () -> field1);
formFactory.setFieldProvider("property2", () -> field2);

field1.addValueChangeListener(event -> {
  ...
  field2.setValue(newCalculatedValue);
});