Skip to content

Instantly share code, notes, and snippets.

<h2>Leave a comment</h2>
<form #f="ngForm" (ngSubmit)="submit(f)">
<div ngModelGroup="contact" #contact="ngModelGroup">
<div *ngIf="!contact.valid">...</div>
<div class="form-group">
<label for="firstName">First Name</label>
<input
required
minlength="3"
maxlength="10"
@wpflames
wpflames / app.component.html
Created June 27, 2022 15:29
Disable submit button
<h2>Leave a comment</h2>
<form #f="ngForm" (ngSubmit)="submit(f)">
<div ngModelGroup="contact" #contact="ngModelGroup">
<div *ngIf="!contact.valid">...</div>
<div class="form-group">
<label for="firstName">First Name</label>
<input
required
minlength="3"
maxlength="10"
@wpflames
wpflames / app.component.html
Created June 27, 2022 15:06
ngForm example
<h2>Leave a comment</h2>
<form #f="ngForm" (ngSubmit)="submit(f)">
<div class="form-group">
<label for="firstName">First Name</label>
<input
required
minlength="3"
maxlength="10"
pattern="banana"
ngModel
@wpflames
wpflames / app.component.html
Created June 27, 2022 14:38
Form validation
<h2>Leave a comment</h2>
<form>
<div class="form-group">
<label for="firstName">First Name</label>
<input
required
minlength="3"
maxlength="10"
pattern="banana"
ngModel
@wpflames
wpflames / app.component.html
Created June 27, 2022 12:07
Form validation
<h2>Leave a comment</h2>
<form>
<div class="form-group">
<label for="firstName">First Name</label>
<input
ngModel
name="firstName"
#firstName="ngModel"
(change)="log(firstName)"
type="text"
@wpflames
wpflames / app.component.ts
Last active June 27, 2022 11:59
Template driven forms
import { Component } from '@angular/core';
@Component({
selector: 'contact-form',
templateUrl: './contact-form.component.html',
styleUrls: ['./contact-form.component.scss']
})
export class ContactFormComponent {
log(x) { console.log(x); }
@wpflames
wpflames / post-object.php
Last active April 24, 2022 11:47
ACF Post Object
<?php if( have_rows('repeater') ): ?>
<?php while ( have_rows('repeater') ) : the_row(); ?>
<?php $post_object = get_sub_field('post_object'); ?>
<?php if( $post_object ): ?>
<?php $post = $post_object; setup_postdata( $post );
@wpflames
wpflames / option-pages.php
Created April 19, 2022 14:26
ACF Option Pages template
<div id="boxes" class="container">
<div class="grid-2">
<?php if( have_rows('repeater_boxes', 'option') ): ?>
<?php while( have_rows('repeater_boxes', 'option') ): the_row(); ?>
<?php if( have_rows('group_box', 'option') ): ?>
<?php while( have_rows('group_box', 'option') ): the_row();
$title = get_sub_field('title', 'option');
@wpflames
wpflames / acf-repeater.php
Created April 11, 2022 10:26
Accordion with acf repeater php template file
<div class="accordion-wrapper">
<?php if(get_field('repeater_root')): ?>
<?php while(has_sub_field('repeater_root')): ?>
<h2 class="headline accordion-title"><?php the_sub_field('repeater_heading'); ?></h2>
<div class="accordion-panel">
<?php if(get_sub_field('repeater_item')): ?>
@wpflames
wpflames / accordion.js
Created April 11, 2022 10:24
Accordion with Vanilla JS
const accTitle = document.getElementsByClassName("accordion-title");
let i;
for (i = 0; i < accTitle.length; i++) {
accTitle[i].addEventListener("click", function() {
this.classList.toggle("active");
let panel = this.nextElementSibling;
panel.classList.toggle("active");
});
}