Vueform is coming this autumn! Sign up for pre-release now to get early access!

Form Builder Framework for Vue.js

Vueform standardizes form creation to make development smoother

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <form @submit.prevent="submit">
    <h2>Registration</h2>
    <Group
      name="name"
      label="Personal information"
    >
      <Text
        name="first_name"
        placeholder="First name"
        rules="required"
        columns="6" />

      <Text
        name="last_name"
        placeholder="Last name"
        rules="required"
        columns="6" />
    </Group>

    <Text
      name="email"
      placeholder="Email"
      rules="required|email|unique"
      label="Account information" />

    <Password
      name="password"
      placeholder="Password"
      rules="required|min:8|confirmed" />

    <Password
      name="password_confirmation"
      placeholder="Password again"
      rules="required" />

    <Toggle
      name="remember_me"
      text="Remember me" />

    <Button
      type="submit" 
      label="Submit" 
      class="btn-default" />
  </form>
</template>

<script>
  import { Vueform, useVueform } from 'vueform'

  export default {
    mixins: [Vueform],
    setup: useVueform,
    data: () => ({
      endpoint: '/api/v1/user',
      method: 'POST'
    }),
    mounted() {
      this.on('success', () => {
        console.log(this.data)
        alert('Registration successful')
        this.reset()
      })
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// The same form can be defined with a simple `schema` object.
// In this case Vueform will use its built-in template that
// renders elements, errors, buttons, etc. based on data.

import { Vueform, useVueform } from 'vueform'

export default {
  mixins: [Vueform],
  setup: useVueform,
  data: () => ({
    endpoint: '/api/v1/user',
    method: 'POST',
    schema: {
      name: {
        type: 'group',
        label: 'Personal information',
        schema: {
          first_name: {
            type: 'text',
            placeholder: 'First name',
            rules: 'required',
            columns: 6
          },
          last_name: {
            type: 'text',
            placeholder: 'Last name',
            rules: 'required',
            columns: 6
          },
          email: {
            type: 'text',
            label: 'Account information',
            placeholder: 'Email',
            rules: 'required|email'
          },
          password: {
            type: 'password',
            placeholder: 'Password',
            rules: 'required|min:8|confirmed'
          },
          password_confirmation: {
            type: 'password',
            placeholder: 'Password again',
            rules: 'required'
          },
          remember_me: {
            type: 'toggle',
            text: 'Remember me'
          },
          buttons: {
            type: 'buttons',
            buttons: [{
              type: 'submit',
              label: 'Submit',
              class: 'btn-default'
            }]
          }
        }
      }
    }
  }),
  mounted() {
    this.on('success', () => {
      console.log(this.data)
      alert('Registration successful')
      this.reset()
    })
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
import { Vueform, useVueform } from 'vueform'
import SummaryElement from './../elements/SummaryElement'
import PaymentElement from './../elements/PaymentElement'
import ShippingMethodRadioSlot from './../elements/slots/ShippingMethodRadioSlot'

export default {
  mixins: [Vueform],
  setup: useVueform,
  data: () => ({
    endpoint: '/api/v1/order',
    method: 'POST',

    // Defining form steps
    wizard: {

      // 1st step - 'Customer information'
      customer_information: {
        label: 'Customer information',
        elements: ['contact_information', 'shipping_address'],
        labels: {
          next: 'Continue to shipping method'
        },
        buttons: {
          previous: false
        }
      },

      // 2nd step - 'Shipping method'
      shipping_method: {
        label: 'Shipping method',
        elements: ['shipping_summary', 'shipping_method'],
        labels: {
          previous: '< Back',
          next: 'Continue to payment'
        }
      },

      // 3rd step - 'Payment method'
      payment_method: {
        label: 'Payment method',
        elements: ['payment_summary', 'payment_method', 'billing_address', 'remember_me', 'terms'],
        labels: {
          previous: '< Back',
          finish: 'Complete order'
        }
      },
    },

    // Defining form elements
    schema: {

      // 'Contact information' (email)
      contact_information: {
        type: 'group',
        label: 'Contact information',
        schema: {
          email: {
            type: 'text',
            placeholder: 'Email',
            label: false,
            floating: 'Email',
            rules: 'required|email:debounce=300',
          },
          updates: {
            type: 'checkbox',
            label: false,
            text: 'Keep me up to date on news and exclusive offers',
          },
        }
      },

      // 'Shipping address' (name, company, address fields, phone)
      shipping_address: {
        type: 'group',
        label: 'Shipping address',
        schema: {
          firstname: {
            type: 'text',
            placeholder: 'First name (optional)',
            floating: 'First name (optional)',
            columns: 6
          },
          lastname: {
            type: 'text',
            placeholder: 'Last name',
            floating: 'Last name',
            rules: 'required',
            columns: 6
          },
          company: {
            type: 'text',
            floating: 'Company (optional)',
            placeholder: 'Company (optional)',
          },
          address: {
            type: 'text',
            floating: 'Address',
            placeholder: 'Address',
            rules: 'required'
          },
          address2: {
            type: 'text',
            floating: 'Apartment, suite, etc. (optional)',
            placeholder: 'Apartment, suite, etc. (optional)',
          },
          city: {
            type: 'text',
            floating: 'City',
            placeholder: 'City',
            rules: 'required'
          },
          country: {
            type: 'select',
            floating: 'Country',
            placeholder: 'Country',
            rules: 'required',
            items: {
              'de': 'Germany',
              'us': 'United States',
            },
            columns: 8
          },
          state: {
            type: 'select',
            floating: 'State',
            placeholder: 'State',
            columns: 4,
            items: states,
            rules: 'required',
            // Should only appear if the country is USA
            conditions: [
              ['shipping_address.country', 'us']
            ],
          },
          zip_code: {
            type: 'text',
            floating: 'ZIP Code',
            placeholder: 'ZIP Code',
            rules: 'required',
            columns: 4
          },
          phone: {
            type: 'text',
            floating: 'Phone',
            placeholder: 'Phone',
            rules: 'required',
            // Using some fancy text mask
            mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
          },
        }
      },

      // Shipping summary block with custom SummaryElement imported at top
      shipping_summary: {
        component: SummaryElement,
        items: ['contact', 'ship_to']
      },

      // 'Shipping method' - using custom template for checkboxes
      shipping_method: {
        type: 'radiogroup',
        label: 'Shipping method',
        before: '<span class="group-description">Please Note - Orders will be ship the next business day. Please add one shipping day to all estimates.</span>',
        items: shippingUS,
        rules: 'required',
        slots: {
          radio: ShippingMethodRadioSlot,
        }
      },

      // Payment summary block with custom SummaryElement imported at top
      payment_summary: {
        component: SummaryElement,
        items: ['contact', 'ship_to', 'method']
      },

      // 'Payment method' block
      payment_method: {
        type: 'group',
        label: 'Payment method',
        class: 'payment-method',
        before: '<span class="group-description">All transactions are secure and encrypted.</span>',
        schema: {

          // 'Credit card' option
          credit_card: {
            type: 'radio',
            text: 'Credit card',
            fieldName:  'payment_method',
            after: '<span class="card-logos"></span>',
            rules: [
              {
                required: ['payment_method.paypal', null]
              }
            ],
            messages: {
              required: 'One payment method must be choosen.'
            }
          },

          // Credit card details (if selected)
          credit_card_details: {
            type: 'group',
            class: 'credit-card-details',
            // Only appears if credit card is selected
            conditions: [
              ['payment_method.credit_card', 1]
            ],
            // Defines its child elements for credit card info
            schema: {
              card_number: {
                type: 'text',
                floating: 'Card number',
                placeholder: 'Card number (do not provide actual card number)',
              },
              cardholder_name: {
                type: 'text',
                floating: 'Cardholder name',
                placeholder: 'Cardholder name',
                columns: 6
              },
              expiration: {
                type: 'text',
                floating: 'MM / YY',
                placeholder: 'MM / YY',
                columns: 3
              },
              cvv: {
                type: 'text',
                floating: 'CVV',
                placeholder: 'CVV',
                columns: 3
              },
            }
          },

          // 'Paypal' option
          paypal: {
            type: 'radio',
            text: ' ',
            class: 'paypal-payment',
            fieldName:  'payment_method',
            after: '<span class="card-logos only-3"></span>',
            rules: [
              {
                required: ['payment_method.credit_card', null]
              }
            ],
            messages: {
              required: 'One payment method must be choosen.'
            }
          },
          // Paypal info window (if selected)
          paypal_payment: {
            component: PaymentElement,
            text: 'After clicking "Complete order", you will be redirected to PayPal to complete your purchase securely.',
            // Only appears if 'credit card' is selected
            conditions: [
              ['payment_method.paypal', 1]
            ],
          },
        },
      },

      // 'Billing address' block
      billing_address: {
        type: 'object',
        label: 'Billing address',
        class: 'billing-address',
        schema: {
          same: {
            type: 'radio',
            text: 'Same as shipping address',
            fieldName:  'billing_address',
            rules: [
              {
                required: ['billing_address.different', null]
              }
            ],
            messages: {
              required: 'One billing address option must be choosen.'
            }
          },
          different: {
            type: 'radio',
            text: 'Use a different billing address',
            fieldName:  'billing_address',
            rules: [
              {
                required: ['billing_address.same', null]
              }
            ],
            messages: {
              required: 'One billing address option must be choosen.'
            }
          },

          // Billing info block (if 'use different is selected')
          billing_info: {
            type: 'group',
            class: 'billing-address-fields',
            // Only appears if 'different' is selected
            conditions: [
              ['billing_address.different', 1]
            ],
            // Defines its child elements for billing info
            schema: {
              firstname: {
                type: 'text',
                placeholder: 'First name (optional)',
                floating: 'First name (optional)',
                columns: 6,
              },
              lastname: {
                type: 'text',
                placeholder: 'Last name',
                floating: 'Last name',
                columns: 6,
                rules: 'required'
              },
              company: {
                type: 'text',
                placeholder: 'Company (optional)',
                floating: 'Company (optional)',
              },
              address: {
                type: 'text',
                placeholder: 'Address',
                floating: 'Address',
                rules: 'required'
              },
              address2: {
                type: 'text',
                placeholder: 'Apartment, suite, etc. (optional)',
                floating: 'Apartment, suite, etc. (optional)',
              },
              city: {
                type: 'text',
                placeholder: 'City',
                floating: 'City',
                rules: 'required'
              },
              country: {
                type: 'select',
                floating: 'Country',
                placeholder: 'Country',
                items: {
                  'de': 'Germany',
                  'us': 'United States',
                },
                columns: 8,
                rules: 'required',
              },
              state: {
                type: 'select',
                floating: 'State',
                placeholder: 'State',
                columns: 4,
                items: states,
                rules: 'required',
                // Should only appear if the country is USA
                conditions: [
                  ['billing_address.billing_info.country', 'us']
                ],
              },
              zip_code: {
                type: 'text',
                floating: 'ZIP Code',
                placeholder: 'ZIP Code',
                rules: 'required',
                columns: 4
              },
              phone: {
                type: 'text',
                placeholder: 'Phone',
                floating: 'Phone',
                rules: 'required'
              },
            }
          }
        },
      },

      // 'Remember me' block
      remember_me: {
        type: 'group',
        label: 'Remember me',
        class: 'remember-me',
        schema: {
          // 'Remember me' checkbox
          remember: {
            type: 'checkbox',
            text: 'Save my information for faster checkout',
          },

          // 'Mobile phone number' input (if 'Remember me' is checked)
          mobile_phone_number: {
            type: 'text',
            class: 'remember-me-number',
            floating: 'Mobile phone number',
            placeholder: 'Mobile phone number',
            mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
            addon: {
              before: '<span class="phone-icon"></span>'
            },
            columns: {
              field: 6
            },
            rules: 'required',
            // Only appears if 'Remember me' is checked) 
            conditions: [
              ['remember_me.remember', true]
            ],
          },

          // Additional description for 'Mobile phone number' (if 'Remember me' is checked)
          phone_description: {
            type: 'static',
            class: 'phone-description',
            content: '<span class="field-description">Next time you check out here or other stores, we will send you an authorization code by SMS to secure your purchase.</span>',
            // Only appears if 'Remember me' is checked) 
            conditions: [
              ['remember_me.remember', true]
            ]
          }
        }
      },

      // 'Accept terms' checkbox (if 'Remember me' is checked)
      terms: {
        type: 'static',
        content: '<span class="accept-terms">By continuing, you agree to our <a href="#">Privacy Policy</a> and <a href="#">Terms of Service</a>.</span>',
        // Only appears if 'Remember me' is checked) 
        conditions: [
          ['remember_me.remember', true]
        ],
      }
    },

    // Selected theme
    theme: 'shopify',
  }),

  // Update columns and shipping options on country change
  watch: {
    'data.country': {
      handler(country) {
        this.el$('shipping_method').items = this.shippingOptions[country || 'us']
        this.el$('shipping_address.country').updateColumns(country == 'us' ? 5 : 8)
        this.el$('shipping_address.zip_code').updateColumns(country == 'us' ? 3 : 4)
      },
    },
    'data.billing_address.country': {
      handler(country) {
        this.el$('billing_address.billing_info.country').updateColumns(country == 'us' ? 5 : 8)
        this.el$('billing_address.billing_info.zip_code').updateColumns(country == 'us' ? 3 : 4)
      },
    },
  },

  computed: {
    shippingOptions(){
      return {
        us: {
          usps: {
            carrier: 'USPS Priority Mail Express',
            delivery_date: '1 business days',
            price: '$66.46'
          },
          fedex: {
            carrier: 'FedEx Home Delivery',
            delivery_date: '1 to 5 business days',
            price: '$66.98'
          },
          ups: {
            carrier: 'UPS Second Day Air',
            delivery_date: '2 business days',
            price: '$120.82'
          },
        },
        de: {
          eu: {
            carrier: 'Free EU Shipping',
            delivery_date: '2-3 business days',
            price: 'FREE'
          }
        }
      }
    }
  },

  mounted() {
    this.on('success', () => {
      console.log(this.filtered)
      alert('Order sent')
      this.reset()
    })
  }
}

const states = {
  AL: 'Alabama', AK: 'Alaska', AZ: 'Arizona', AR: 'Arkansas', CA: 'California', CO: 'Colorado',
  CT: 'Connecticut', DE: 'Delaware', DC: 'District Of Columbia', FL: 'Florida', GA: 'Georgia',
  HI: 'Hawaii', ID: 'Idaho', IL: 'Illinois', IN: 'Indiana', IA: 'Iowa', KS: 'Kansas', KY: 'Kentucky',
  LA: 'Louisiana', ME: 'Maine', MD: 'Maryland', MA: 'Massachusetts', MI: 'Michigan', MN: 'Minnesota',
  MS: 'Mississippi', MO: 'Missouri', MT: 'Montana', NE: 'Nebraska', NV: 'Nevada', NH: 'New Hampshire',
  NJ: 'New Jersey', NM: 'New Mexico', NY: 'New York', NC: 'North Carolina', ND: 'North Dakota',
  OH: 'Ohio', OK: 'Oklahoma', OR: 'Oregon', PA: 'Pennsylvania', RI: 'Rhode Island', SC: 'South Carolina',
  SD: 'South Dakota', TN: 'Tennessee', TX: 'Texas', UT: 'Utah', VT: 'Vermont', VA: 'Virginia',
  WA: 'Washington', WV: 'West Virginia', WI: 'Wisconsin', WY: 'Wyoming'
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<template>
  <form @submit.prevent="submit">
    <h2>Basic data</h2>

    <Text
      name="title"
      label="Position name"
      description="Name the position (eg. Marketing intern, IT fresh graduate program)"
      rules="required"
    />

    <Location
      :conditions="[['default_location', false]]"
      name="location"
      label="Place of work"
      placeholder="Add the exact address of the work"
      provider="google"
      rules="required"
    />

    <Checkbox
      name="default_location"
      :text="`The place of work is the same as in your company profile: <i>${company_address}</i>`"
    />

    <Radiogroup
      name="job_type"
      rules="required"
      appearance="pills"
      :items="['Internship', 'Graduate', 'Voluntary', 'Junior']"
    />

    <Tags
      name="categories"
      label="Job categories"
      rules="required|max:3"
      description="Select up to 3"
      :search="true"
      :items="categories"
    />

    <Slider
      name="work_hours"
      label="Required minimum weekly working hours"
      min="1"
      max="40"
      default="20"
      :format="v => v > 1 ? `${v} hours` : '1 hour'"
    />

    <Group
      name="salary"
      label="payment"
    >
      <Select
        name="has_salary"
        placeholder="Select"
        rules="required"
        :native="false"
        :items="{1: 'Paid', 0: 'Unpaid'}"
        :columns="{lg:4,sm:6}"
      />

      <Text
        name="salary"
        placeholder="Amount"
        rules="integer"
        :columns="{lg:4,sm:6}"
        :conditions="[['salary.has_salary', 1]]"
      />

      <Select
        name="salary_currency"
        default="usd"
        :native="false"
        :items="{usd: 'USD', eur: 'EUR'}"
        :columns="{lg:4,sm:6}"
        :conditions="[['salary.has_salary', 1]]"
      />

      <Select
        name="salary_period"
        default="weekly"
        :native="false"
        :items="{hourly: '/ hour', daily: '/ day', weekly: '/ week', monthly: '/ month'}"
        :columns="{lg:4,sm:6}"
        :conditions="[['salary.has_salary', 1]]"
      />
    </Group>

    <h2>Schedule</h2>

    <Date
      name="application_deadline"
      label="Application deadline"
      rules="required"
      :conditions="[['continuous_application'], false]"
    />

    <Checkbox
      name="continuous_application"
      text="Can apply continuously"
    />

    <Group
      name="job_period"
    >
      <Group
        name="job_start_group"
        columns="6"
      >
        <Date
          name="job_start_date"
          label="Getting started"
          rules="required"
          :conditions="[['job_period.job_start_group.job_start_immediate'], false]"
        />

        <Checkbox
          name="job_start_immediate"
          text="Immediately"
        />
      </Group>

      <Group
        name="job_end_group"
        columns="6"
      >
        <Date
          name="job_end_date"
          label="End of work"
          rules="required"
          :conditions="[['job_period.job_end_group.job_end_indefinite'], false]"
        />

        <Checkbox
          name="job_end_indefinite"
          text="Indefinite"
        />
      </Group>
    </Group>

    <h2>Requirements</h2>

    <List
      name="languages"
      min="1"
    >
      <Object>
        <Select
          name="language_id"
          placeholder="Language"
          rules="required"
          columns="6"
          :search="true"
          :items="languages"
        />

        <Select
          name="language_level"
          placeholder="Level"
          rules="required"
          columns="6"
          :items="{25: 'Beginner', 50: 'Intermediate', 75: 'Advanced', 100: 'Native'}"
        />
      </Object>
    </List>

    <Checkbox
      name="student_status_required"
      label="Student status"
      text="Student status is required for the job"
      :trueValue="1"
      :falseValue="0"
    />

    <Checkbox
      name="degree"
      label="Degree"
      text="Degree is required for work"
      :trueValue="1"
      :falseValue="0"
    />

    <Select
      name="degree_requirement"
      placeholder="Degree level"
      :columns="{lg:5,sm:6}"
      :items="{50: 'BA/BSc', 75: 'MA/MSc', 100: 'PhD'}"
      :conditions="[['degree', 1]]"
    />

    <Tags
      name="professional_skills"
      label="Professional skills"
      description="Choose as many as you can"
      :createTag="true"
      :items="professional_skills"
    />

    <Tags
      name="computer_skills"
      label="Computer skills"
      description="Choose as many as you can"
      :createTag="true"
      :items="computer_skills"
    />

    <Tags
      name="soft_skills"
      label="Soft skills"
      description="Choose as many as you can"
      :createTag="true"
      :items="soft_skills"
    />

    <h2>Job description</h2>

    <Trix
      name="description"
      label="Position description, tasks"
    />

    <Trix
      name="requirements"
      label="Requirements"
    />

    <Trix
      name="offer"
      label="What we offer"
    />

    <h2>How to apply</h2>

    <Radio
      name="internal_application"
      fieldName="application_type"
      text="<b>Recommended</b>: Apply with profile"
      description="Select this if you want to rely on our internal application tracking system"
    />

    <Group
      name="feedback"
      label="Auto reply message for applicants"
      before="Here you can write messages in advance you would like to send out to applicants when you accept or reject their application."
      :conditions="[['internal_application', true]]"
    >
      <FeedbackTypeSelectElement
        :paths="['feedback.accept_feedback', 'feedback.reject_feedback']"
      />

      <Trix
        name="accept_feedback"
        placeholder="Successful application message"
        default="Congratulations! You're application has been accepted. We'll contact you soon."
        rules="required"
      />

      <Trix
        name="reject_feedback"
        placeholder="Unsuccessful application message"
        default="Unfortunately you haven't been selected in round. We wish you the best of luck next time!"
        rules="required"
      />
    </Group>

    <Radio
      name="external_application"
      fieldName="application_type"
      text="Forward candidates to an external site"
      description="Select this if you want to rely on an external application tracking system"
    />

    <Text
      :conditions="[['external_application', true]]"
      name="external_url"
      label="Add link"
      placeholder="eg. https://yourcompany.com/job-title"
      rules="required|url"
    />

    <h2>Pictures and videos</h2>

    <Image
      name="cover"
      label="Cover image"
      description="This is the first image job seekers will see at the top of your ad. Use a high quality image. Recommended image size: 1640x720px (Similar to <a href='https://blog.snappa.com/facebook-cover-photo-size/' target='_blank'>Facebook cover photo</a> size)"
      rules="required|max:5000"
      :auto="false"
      :conditions="[['default_cover'], false]"
    />

    <Checkbox
      name="default_cover"
      text="Use the cover image provided in your company profile"
    />

    <Gallery
      name="gallery"
      label="Image gallery (optional)"
      rules="max:8"
      :sort="true"
      :file="{rules:'required|max:3000'}"
      :auto="false"
    />

    <List
      name="youtubes"
      label="Youtube Video (Optional)"
    >
      <Text
        name="yotube"
        component="YoutubeElement"
        description="Copy your Youtube video <b>ID</b> . Ex: https://www.youtube.com/watch?v= <b>welpvNwbw0E</b>"
        rules="required|size:11"
        :addons="{before:'https://www.youtube.com/watch?v='}"
      />
    </List>

  </form>
</template>

<script>
  import axios from 'axios'
  import { Vueform, useVueform } from 'vueform'
  import FeedbackTypeSelectElement from './../elements/FeedbackTypeSelectElement'
  import YoutubeElement from './../elements/YoutubeElement'

  export default {
    mixins: [Vueform],
    components: {
      FeedbackTypeSelectElement,
      YoutubeElement,
    },
    setup: useVueform,
    data: () => ({
      categories: async () => {
        return await axios.get('/job-categories')
      },
      languages: async () => {
        return await axios.get('/languages')
      },
      professional_skills: async () => {
        return await axios.get('/skills?type=professional')
      },
      computed_skills: async () => {
        return await axios.get('/skills?type=computer')
      },
      job_skills: async () => {
        return await axios.get('/skills?type=job')
      },
    }),
    computed: {
      company_address() {
        return '1600 Amphitheatre Parkway in Mountain View, California, United States'
      }
    },
    mounted() {
      this.on('success', () => {
        console.log(this.filtered)
        alert('Job posted')
        this.reset()
      })
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// Using Composition API

import { Vueform, useVueform } from 'vueform'
import { ref, computed, markRaw } from 'vue'

export default {
  mixins: [Vueform],
  setup(props, context) {
    const vueform = useVueform(props, context)

    // The `el$` method returns an element based on its `path`
    const el$ = vueform.el$

    // Create tabs for `Questions` and `Preview`
    const tabs = ref({
      questions: {
        label: 'Questions',
        elements: ['questions']
      },
      preview: {
        label: 'Preview',
        elements: ['preview']
      }
    })

    // Schema is now dynamic
    const schema = computed(() => {
      return {
        
        // Defining questions list
        questions: {
          type: 'list',
          default: [
            { question: 'What is your name?' }
          ],

          // This is how each question should look like
          object: {
            schema: {

              // Using custom component to display question number
              title: {
                type: 'static',
                content: markRaw({
                  props: ['el$'],
                  template: `<h3>Question</h3>`,
                  computed: {
                    number() {
                      return parseInt(this.el$.parent.name) + 1
                    }
                  },
                })
              },

              type: {
                type: 'select',
                default: 'short_answer',
                label: 'Choose type:',
                placeholder: 'Type',
                items: [
                  'Short answer',
                  'Paragraph',
                  'Multiple choice',
                  'Checkboxes',
                  'Dropdown',
                ],
              },

              question: {
                type: 'text',
                placeholder: 'Question',
                label: 'Question:'
              },

              description: {
                type: 'textarea',
                placeholder: 'Description (optional)',
                rows: 2
              },

              // Will only appear if Multiple choice is selected
              multiple_choice: {
                type: 'list',
                label: 'Options:',
                element: {
                  type: 'text',
                  placeholder: 'Option'
                },
                conditions: [
                  ['questions.*.type', 2]
                ]
              },

              // Will only appear if Checkboxes is selected
              checkboxes: {
                type: 'list',
                label: 'Options:',
                element: {
                  type: 'text',
                  placeholder: 'Option'
                },
                conditions: [
                  ['questions.*.type', 3]
                ]
              },

              // Will only appear if Dropdown is selected
              dropdown: {
                type: 'list',
                label: 'Options:',
                element: {
                  type: 'text',
                  placeholder: 'Option'
                },
                conditions: [
                  ['questions.*.type', 4]
                ]
              },
            }
          }
        },

        // Defining preview
        preview: {
          type: 'object',
          // Note that we're using the computed `preview` value
          schema: preview.value,
        }
      }
    })

    // Creating a dynamic schema based on `questions`
    const preview = computed(() => {
      let schema = {}

      el$('questions').children$.forEach((question, key) => {
        schema[key] = {
          label: question.value.question || false,
          description: question.value.description || null,
        }

        switch (question.value.type) {
          case 'short_answer':
            schema[key].type = 'text'
            break

          case 'paragraph':
            schema[key].type = 'textarea'
            break

          case 'multiple_choice':
            schema[key].type = 'radiogroup'
            schema[key].items = question.children$.multiple_choice.value
            break

          case 'checkboxes':
            schema[key].type = 'checkboxgroup'
            schema[key].items = question.children$.checkboxes.value
            break

          case 'dropdown':
            schema[key].type = 'select'
            schema[key].items = question.children$.dropdown.value
            break
        }
      })

      return schema
    })

    return {
      ...vueform,
      tabs,
      schema,
    }
  }
}
Comprehensive

Vueform embraces all the features a developer might need, whether it's advanced elements, wizard, validation or data & response processing, while keeping things highly customizable.

Powerful

With Vueform your productivity will skyrocket. Bring out the most of your team or even outsource complex parts of the frontend code while staying assured of the quality of the result.

Scalable

Vueform standardizes every aspect of form development. It not only saves development time and cost, but will also increase the overall quality of your codebase, making it more scalable.

Signup for pre-release

Sign up to our pre-release program and access Vueform when it becomes available

Features

Vueform includes all the features you'll ever need to create even the most complex forms

Advanced elements

Choose from 30+ elements including advanced, nested and repeatable elements or create your custom one

File uploads

Accept multiple files or images using a single line of code without the hassle of any manual work

Validation

Validate elements using 50+ built-in or custom validators with dependent and conditional capabilities

Conditional logic

Use conditions across your form including in elements, tabs, steps or simple DOM elements

Multi-step wizard

Break your form into steps and allow users to go through even the most complex ones smoothly

CSS framework support

Customize theme and layout easily whether you are using Tailwind, Bootstrap or Material

Internationalization (i18n)

Translate forms easily with vue-i18n integration or create your own custom translation service

Event hooks

Subscribe to events and hooks on an element or form level to customize form behaviour

Tree-shakeable

Keep your bundle sizes low and rely on tree-shaking with ESM modules provided by Vueform

Extensible

Create elements, validators, replace components or rewrite a theme to your needs

Reactive configuration

All configurations in Vueform are reactive, so you can add elements or change properties on the flight

API access

Vueform has an extensive API to which allows you to reach any part of the form from any component

Signup for pre-release

Sign up to our pre-release program and access Vueform when it becomes available