pub struct ValidationFormContext { /* private fields */ }

Implementations§

Examples found in repository?
src/form/mod.rs (lines 205-208)
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
    fn view(&self, ctx: &Context<Self>) -> Html {
        let mut classes = Classes::from("pf-c-form");

        classes.extend(ctx.props().horizontal.clone());

        if ctx.props().limit_width {
            classes.push("pf-m-limit-width");
        }

        let alert = &ctx.props().alert;
        let validation_alert = Self::make_alert(
            self.validation.state,
            (
                ctx.props()
                    .validation_warning_title
                    .as_deref()
                    .unwrap_or("The form contains fields with warnings."),
                &html!(),
            ),
            (
                ctx.props()
                    .validation_error_title
                    .as_deref()
                    .unwrap_or("The form contains fields with errors."),
                &html!(),
            ),
        );

        // reduce by severity

        let alert = match (alert, &validation_alert) {
            (None, None) => None,
            (Some(alert), None) | (None, Some(alert)) => Some(alert),
            (Some(props), Some(validation)) if validation.r#type > props.r#type => Some(validation),
            (Some(props), Some(_)) => Some(props),
        };

        let validation_context = ValidationFormContext::new(
            ctx.link().callback(Msg::GroupValidationChanged),
            self.validation.state,
        );

        html! (
            <ContextProvider<ValidationFormContext> context={validation_context} >
                <form
                    novalidate=true
                    class={classes}
                    id={ctx.props().id.clone()}
                    action={ctx.props().action.clone()}
                    method={ctx.props().method.clone()}
                >

                    if let Some(alert) = alert {
                        <div class="pf-c-form__alert">
                            <Alert
                                inline=true
                                r#type={alert.r#type}
                                title={alert.title.clone()}
                                >
                                { alert.children.clone() }
                            </Alert>
                        </div>
                    } else {
                        <div style="display: none;"></div>
                    }

                    { for ctx.props().children.iter() }

                </form>
            </ContextProvider<ValidationFormContext>>
        )
    }
Examples found in repository?
src/form/group.rs (line 239)
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
    fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
        match msg {
            Self::Message::Validate(value) => {
                let state = ctx.props().validator.run(value);
                if self.state != state {
                    self.state = state;
                    ctx.props()
                        .onvalidated
                        .emit(self.state.clone().unwrap_or_default());
                    if let Some((validation_ctx, _)) = ctx
                        .link()
                        .context::<ValidationFormContext>(Callback::noop())
                    {
                        validation_ctx
                            .push_state(GroupValidationResult(self.id.clone(), self.state.clone()));
                    }
                }
            }
        }
        true
    }
Examples found in repository?
src/form/group.rs (line 252)
247
248
249
250
251
252
253
254
    fn destroy(&mut self, ctx: &Context<Self>) {
        if let Some((ctx, _)) = ctx
            .link()
            .context::<ValidationFormContext>(Callback::noop())
        {
            ctx.clear_state(self.id.clone());
        }
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert self to a value of a Properties struct.
Convert self to a value of a Properties struct.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more