Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add urlField #1885

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Guide/form.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ IHP has the most commonly-used form controls built in. In general the form contr
- [`{passwordField #password}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:passwordField)
- [`{dateTimeField #createdAt}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:dateTimeField)
- [`{numberField #quantity}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:numberField)
- [`{urlField #url}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:urlField)
- [`{hiddenField #projectId}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:hiddenField)
- [`{checkboxField #termsAccepted}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:checkboxField)
- [`{selectField #projectId allProjects}`](https://ihp.digitallyinduced.com/api-docs/IHP-View-Form.html#v:selectField)
Expand Down
1 change: 1 addition & 0 deletions IHP/View/CSSFramework.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ instance Default CSSFramework where
renderInner = case formField.fieldType of
TextInput -> styledTextFormField cssFramework "text" formField validationResult
NumberInput -> styledTextFormField cssFramework "number" formField validationResult
UrlInput -> styledTextFormField cssFramework "url" formField validationResult
PasswordInput -> styledTextFormField cssFramework "password" formField validationResult
ColorInput -> styledTextFormField cssFramework "color" formField validationResult
EmailInput -> styledTextFormField cssFramework "email" formField validationResult
Expand Down
20 changes: 20 additions & 0 deletions IHP/View/Form.hs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,26 @@ numberField :: forall fieldName model value.
numberField field = (textField field) { fieldType = NumberInput }
{-# INLINE numberField #-}

-- | Renders a URL input field
--
-- >>> {urlField #url}
-- <div class="form-group" id="form-group-company_url">
-- <label for="company_url">Url</label>
-- <input type="url" name="url" id="company_url" class="form-control" />
-- </div>
--
-- See 'textField' for examples of possible form control options.
urlField :: forall fieldName model value.
( ?formContext :: FormContext model
, HasField fieldName model value
, HasField "meta" model MetaBag
, KnownSymbol fieldName
, InputValue value
, KnownSymbol (GetModelName model)
) => Proxy fieldName -> FormField
urlField field = (textField field) { fieldType = UrlInput }
{-# INLINE urlField #-}

-- | Renders a textarea
--
-- >>> {textareaField #body}
Expand Down
1 change: 1 addition & 0 deletions IHP/View/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ instance SetField "customFormAttributes" (FormContext record) [(Text, Text)] whe
data InputType
= TextInput
| NumberInput
| UrlInput
| CheckboxInput
| ColorInput
| EmailInput
Expand Down
Loading