by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Chris Mckay
    @Errorific
    Hi, I'm having some issues with how to hide fields in a form based on other values in the form and was wondering if anyone could point me in the right direction?
    need to hide or unrender some of the fields based on the value of a combobox at the top of the form. Have tried wiring the value of the combo box back into the form from the state but thats triggering re-rendering when I'm typing in other fields and loses focus. Thought maybe mapProps with hidden on the fields that I need to disappear but it doesn't seem like the full form state is available on the fields mapProps.
    pretty sure I'm just missing something obvious in the docs
    David Khourshid
    @davidkpiano
    @Errorific do you have some existing code you can show?
    you can always make a custom control that depends on a certain model
    Chris Mckay
    @Errorific
    I can whip up some code, but theres nothing special in what i'm starting with, just controls wrapped around some customComponents that render the fields. The way I had it losing focus was obviously wrong, I had it listening to too much of the model.
    custom control is always a possibility, was hoping there was a simpler way of visiting the model the form is using from the control
    or maybe is there a way to tell a control to use a model of x.y and use x.y.val as its value for display and validation purposes? then stick some more state beside it like x.y.hidden that I can use in mapProps to feed to the customComponent?
    David Khourshid
    @davidkpiano
    I mean, it's all just redux... every single value that you can possibly ever need is in the redux store
    so just grab it from there
    Chris Mckay
    @Errorific
    That's right I guess, I'm overthinking this somewhere. I think I'm getting stuck on how the controls are being pointed at a specific part of the model and they don't have visibility outside of that, but they do because redux.
    I've got something that works now passing the model field I want out of the forms state into the component that renders my form and switching the fields on and off with that, but it feels like I'm pulling the data from the wrong place. I'll see where I get to with what I have. Thanks
    Dima Doronin
    @ddoronin
    hey!
    First of all, the library is AWESOME! Really!
    But could anybody share good docs or git how to write unit tests for the forms?
    :)
    I was trying to find it in documentation, but without success
    maybe it's there, but I just don't see it...
    Dima Doronin
    @ddoronin
    actually I already found one great example here:
    https://github.com/tylercollier/redux-form-test
    it would be a good idea to reference this repo in docs
    David Khourshid
    @davidkpiano
    @ddoronin that's for redux-form, not react-redux-form
    are you using react-redux-form or redux-form?
    kkashou
    @kkashou
    Hello ... was wondering if I can get any help on this issue davidkpiano/react-redux-form#923
    write2art
    @write2art
    Hello! Have somebody tried to integrate react-datepicker with react-redux-form?
    Kalle Mäkynen
    @kallemakynen
    Hey @davidkpiano. Is there some reasoning behind not "allowing" <Errors /> component's messages to be an object? The component works fine even if it is an object, but I get type error in the browser console: "Failed prop type: Invalid prop messages.isRequired supplied to Errors"
    kkashou
    @kkashou
    @write2art ... yes I have and it works great with it. What questions do you have regarding it ?
    Emmanuel Villegas
    @Ragnarok99
    hi i need a hand with something
    is someone there?
    :)
    write2art
    @write2art
    @kkashou how exactly have you achieved it? My setup is working, but seems a little bit sophisticated to me:
    class DatePickerInput extends Component {
      constructor (props) {
        super(props)
        this.state = {
          startDate: props.value ? moment.unix(props.value) : ''
        };
        this.handleChange = this.handleChange.bind(this);
      }
    
      handleChange(date) {
        this.setState({
          startDate: date
        });
        this.props.onChange(date)
      }
    
      render() {
        return <DatePicker
          name={this.props.name}
          className="form-control"
          dateFormat="DD MMM YYYY"
          locale="ru-ru"
          readOnly={true}
          selected={this.state.startDate}
          onChange={this.handleChange}
          minDate={this.props.minDate}
          maxDate={this.props.maxDate}
          placeholderText="Выберите дату"
        />;
      }
    }
    
    export default class DatePickerControl extends Component {
      customInput(props) {
        return (<DatePickerInput {...props}/>);
      }
    
      render() {
        return (
          <div className="form-group">
            { this.props.label &&
            <label className="control-label" htmlFor={this.props.id}>{this.props.label}</label>}
            <Control {...this.props} className="form-control" component={this.customInput} getValue={(moment) => {
              return parseInt(isNaN(parseInt(moment)) ? moment.format("X") : moment);
            }}/>
          </div>
        );
      }
    }
    Billy Le
    @lebilly

    Hello everyone! I'm fairly new to react and redux and my team is currently using react-redux-form. I have a question but there is some context before I ask.

    I have a form, say the model is 'team', that will make a request to retrieve all data from the db, say 'users', when the component mounts. This users data will have a list of id's and a names. I will map over the names over a dropdown list using the Control.select and the model will point be "team.user.name".

    So what I want to do is use the id to pass in with every option because my model needs the "team.user.id" to save to the db on submit. How is this done?

    David Khourshid
    @davidkpiano
    why not map over the IDs to start with?
    and then display the names based on the IDs (but don't have the names be the values of the options)
    Billy Le
    @lebilly
    Yeah, that's what I ended up doing :) Thanks tho! Took me another day to figure it out.
    kkashou
    @kkashou
    @write2art That sounds about right how I would have done it. What part specifically are you looking at that is little bit sophisticated?
    Lukas Stuart-Fry
    @lstuartfry
    Does anyone have any experience in writing debounced validators? All my ‘change’ actions are debounced 300ms, and I’m trying to figure out the best way to implement a 300ms delay on all my validators.
    Lukas Stuart-Fry
    @lstuartfry
    I’m not handling validation through any manual dispatch actions.
    const required = () => ({ validator: (val) => (val && val.length) });
    <Control
         validators: { required: required().validator }
    />
    Lukas Stuart-Fry
    @lstuartfry
    Actually, this was completely my error. I can leave this message here as a warning for others, but my Control field was actually using a validateOn=“blur” only. Since the model change was debounced 300ms, if a user ‘tabs’ or clicks out of the field before the model can update, it will register as invalid.
    Terry
    @tmcdonnell87
    Was there any breaking change between 1.14 and 1.16? I just upgraded and all of my wrapped controls broke. I can start digging in but if there's a documented upgrade guide would prefer to start there
    It now appears all of my props are being passed straight down to the <input>
    For example, <input label="Email Address" placeholder="Your email" controlprops="[object Object]" validators="[object Object]" messages="[object Object]" name="registration.email" value="a@b.com" fieldprops="[object Object]" class="form-control">
    Terry
    @tmcdonnell87
    Appears it was actually between 1.14.2 and 1.14.4...
    Terry
    @tmcdonnell87
    Circling back to ^, it's a minor problem and logged here: davidkpiano/react-redux-form#1021
    Chris Gruel
    @devorbitus
    Hiya, could someone point me towards some examples of unit testing forms created with react-redux-form. I have a feeling I am over complicating it but would like a reference to be sure.
    David Khourshid
    @davidkpiano
    @devorbitus look at the RRF unit tests. it's not too hard
    the process is just creating a store like you would with combineForms and then selecting inputs, and entering text into them, and checking that the store has the right value.
    Baruch Kogan
    @boriskogan81
    hi, guys. Could anyone explain to me how to initialize field arrays with some field length? the example has a button that is linked to fields.push in the stateless method, but I'd like to start off with several fields, and can't figure it out
    David Khourshid
    @davidkpiano
    @boriskogan81 wrong repo