how to make MDBSelectInput a required field


Topic: how to make MDBSelectInput a required field

Paul TP asked 5 years ago

I am trying to make MDBSelectInput a required field but I am not winning. Below is an example: eturn ( {option.text} ); }); return ( {options} {this.props.label} );


Jakub Chmura staff premium answered 5 years ago

Hi @Paul TP

You probably had a problem with paste example code.

I understand that you want to make MDBSelect as a required field, so then you need just add required props to MDBSelect instead of MDBSelectInput. If you do this everything should work fine.

If there is anything else I could do for you do not hesitate to ask me. I'll be happy to help you.

Best regards,

Kuba


Paul TP commented 5 years ago

hi @Jakub Chmura I have tried that but did not get any luck.

<MDBSelect
                    getTextContent={this.props.getValue}
                    label={this.props.label}
                    required={true}
                >
                    <MDBSelectInput
                        selected={this.props.value}
                        // required={this.props.required}
                        attributes={{
                            id: this.props.id,
                            name: this.props.name,
                            readOnly: false,
                            onChange: this.props.handleChange
                        }}
                    >

Jakub Chmura staff premium commented 5 years ago

Please look to this page. On the top of this page click API and there you can see how to use props on MDBSelect.

I see that you use required on MDBSelectInput but it's not possible to use these props on this component because it doesn't have that props. You can only use selected props on MDBSelectInput.

In the MDBSelect component try to use just required props. not required={true}.

Best regards,

Kuba


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.6.1
  • Device: Laptop
  • Browser: chrome
  • OS: Linux Fedora
  • Provided sample code: No
  • Provided link: No
Tags