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 forms processing #25

Closed
Awilum opened this issue May 25, 2021 · 0 comments
Closed

Add forms processing #25

Awilum opened this issue May 25, 2021 · 0 comments

Comments

@Awilum
Copy link
Member

Awilum commented May 25, 2021

We should have general forms process functionality to simplify and standardize forms handling on the backend.

YAML structure (example):

blocks:
  - type: Form
    process:
      actions:
        - name: createPostOnTwitter
          properties:
            fields: __self.fields
        - name: createPostOnFacebook
          properties:
            fields: __self.fields
      fields:
        - name: title
          type: string
        - name: content
          type: string
        - name: description
          type: string
        - name: routable
          type: bool
        - name: visibility
          type: string
        - name: published_at
          type: string
        - name: publised_by
          type: string
          value: "{{ flextype.acl.getUserLoggedInUuid() }}"
        - name: template 
          type: string
        - name: menu_item_title
          type: string
        - name: menu_item_url
          type: string
        - name: menu_item_target
          type: string
        - name: menu_item_order
          type: int
      messages: 
        error: "{{ __('admin_message_entry_changes_not_saved') }}"               
        success: "{{ __('admin_message_entry_changes_saved') }}"
      redirect:
        route: admin.entries.edit 
        args:
          id: id
          editor: editor
          blueprint: blueprint
          action: action
    properties: 
      name: form_entries_edit
    blocks:
      ...
        ...
          ...

PHP handling (example):

$form = flextype('blueprints')->form($request->getParsedBody());
$form->getActions();

if (flextype('entries')->create($id, $form->getFields())) {
    flextype('flash')->addMessages('success', $form->getMessage('success'));
} else {
    flextype('flash')->addMessages('error', $form->getMessage('error'));
}

return $response->withRedirect($form->getRedirect(['id' => $id, 'type' => $type]));

Epic: #1

@Awilum Awilum self-assigned this May 25, 2021
@Awilum Awilum added this to the 1.0.0 milestone May 25, 2021
Awilum added a commit that referenced this issue Jun 2, 2021
@Awilum Awilum closed this as completed Jun 3, 2021
Awilum added a commit that referenced this issue Jun 3, 2021
- add Template variables.
- use _self_value instead of _self.value
- use _self_fields instead of _self.fields
- use _self_messages instead of _self.messages
- use _self_redirect instead of _self.redirect
Awilum added a commit that referenced this issue Jun 6, 2021
- new public method `storage` to get form storage data
- `process` moved inside `properties`
- new __form_process_ hidden field instead of __process_form_
- new __form_vars_ hidden field instead of __process_vars_
- new actions functionality
- removed properties: process, vars and data, use storage instead
- improved logic for other methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant