@(contact:Option[models.Contact] = None)(implicit errors:Map[String,play.data.validation.Error])

@main(title = contact.map("Contact " + _.id).getOrElse("New contact"), current = "form") {
    
    @form(controllers.Application.save(contact.flatMap(_.id.get))) {

        <input type="hidden" name="contact.id" value="@contact.map(_.id)">

        <p class="field">
            <label for="name">Name:</label>
            <input type="text" id="name" name="contact.name" value="@contact.map(_.name)">
            <span class="error">@errors.get("contact.name")</span>
        </p>

        <p class="field">
            <label for="firstname">First name:</label>
            <input type="text" id="firstname" name="contact.firstname" value="@contact.map(_.firstname)">
            <span class="error">@errors.get("contact.firstname")</span>
        </p>

        <p class="field">
            <label for="birthdate">Birth date:</label>
            <input type="text" id="birthdate" name="contact.birthdate" value="@contact.map(c => Option(c.birthdate).map(_.format("yyyy-MM-dd")))">
            <span class="error">@errors.get("contact.birthdate")</span>
        </p>

        <p class="field">
            <label for="email">Email:</label>
            <input type="text" id="email" name="contact.email" value="@contact.map(_.email)">
            <span class="error">@errors.get("contact.email")</span>
        </p>

        <p class="buttons">
            <a href="@action(controllers.Application.list)">Cancel</a> or <input type="submit" value="Save this contact" id="saveContact">
        </p>

        <script type="text/javascript" charset="utf-8">
            $("#birthdate").datepicker({dateFormat:'yy-mm-dd', showAnim:'fadeIn'})
        </script>
    
    }
    
}

