<p>I'm not aware of any straightforward way to remove that field from the Entry form. You might want to consider creating a small site module, adding some logic in an <a href="https://craftcms.com/knowledge-base/custom-module-events" rel="nofollow noreferrer">event handler</a> to re-write/remove the contents of the expiration date as necessary?</p>

CC BY-SA 4.0
2021-05-04T12:42:06.543Z
Thanks, that's a possible avenue. So use CSS to hide the field in the editor and use custom validations to prevent the entry from being saved if the postdate is not empty. That should work at least. Though I'm worried the postdate might still show up elsewhere ... it would be great if it was possible to remove the field "natively" altogether.
MoritzLost
CC BY-SA 4.0
2021-05-04T14:24:14.400Z
`postDate` is not the same as `expiryDate`, but I'll assume you know that and your namings are mixed up! I don't even think I'd validate the expiration date - if you really don't want it to be set through CP, have the module set the entry's `expiryDate` to null in the `EVENT_BEFORE_SAVE` event. You can't do this with `postDate`, Craft will set it to current date/time.
Wallace
CC BY-SA 4.0
2021-05-06T07:22:56.013Z
Yeah I got that mixed up, I meant the expiration date, just corrected it in the question, thanks! Clearing the expiryDate in a hook is probably the way to go –  of course I'll have to hide the field in CSS then, to make sure nobody tries to set it and get frustrated. Thanks for the suggestions!
MoritzLost
CC BY-SA 4.0
2021-05-04T10:19:46.867Z
2021-05-04T10:19:46.867Z
Wallace
<p>By default, every entry has an expiration date field allowing the editor to expire an entry. I'm currently working on an application with some sections where expiring an entry doesn't make much sense and could break some parts of the site. So I would like to remove the &quot;expiration date&quot; field from some sections, to prevent someone accidentally setting an expiration date, or setting the field believing it to work in a different way than it actually does.</p>
<p>I've found no way to properly remove the field, at least there's no option for that in the section settings. I could just hide the field with CSS and JS, but of course that's not a solid solution. I would prefer a solution that's enforced on API level. Maybe it can be done with a hook? Or is there a better solution for this (except building a custom element type from scratch)?</p>

<entries><sections><entrymodel><expiration>
Remove expiration date field from section / entry type
# Remove expiration date field from section / entry type

(Asked by: username_0 on 2021-05-04)

By default, every entry has an expiration date field allowing the editor to expire an entry. I'm currently working on an application with some sections where expiring an entry doesn't make much sense and could break some parts of the site. So I would like to remove the "expiration date" field from some sections, to prevent someone accidentally setting an expiration date, or setting the field believing it to work in a different way than it actually does.

I've found no way to properly remove the field, at least there's no option for that in the section settings. I could just hide the field with CSS and JS, but of course that's not a solid solution. I would prefer a solution that's enforced on API level. Maybe it can be done with a hook? Or is there a better solution for this (except building a custom element type from scratch)?

**Tags:** entries, sections, entrymodel, expiration


---

## 1 answers

### Answer by username_1 on 2021-05-04. Score: 2 | Accepted answer

I'm not aware of any straightforward way to remove that field from the Entry form. You might want to consider creating a small site module, adding some logic in an [event handler](https://craftcms.com/knowledge-base/custom-module-events) to re-write/remove the contents of the expiration date as necessary?

> **Comments:**
> **username_0**: Thanks, that's a possible avenue. So use CSS to hide the field in the editor and use custom validations to prevent the entry from being saved if the postdate is not empty. That should work at least. Though I'm worried the postdate might still show up elsewhere ... it would be great if it was possible to remove the field "natively" altogether.  
> **username_1**: `postDate` is not the same as `expiryDate`, but I'll assume you know that and your namings are mixed up! I don't even think I'd validate the expiration date - if you really don't want it to be set through CP, have the module set the entry's `expiryDate` to null in the `EVENT_BEFORE_SAVE` event. You can't do this with `postDate`, Craft will set it to current date/time.  
> **username_0**: Yeah I got that mixed up, I meant the expiration date, just corrected it in the question, thanks! Clearing the expiryDate in a hook is probably the way to go –  of course I'll have to hide the field in CSS then, to make sure nobody tries to set it and get frustrated. Thanks for the suggestions!  

---

